[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6681":3},{"id":4,"name":5,"fullName":6,"owner":5,"repo":5,"description":7,"homepage":8,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":17,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":21,"topics":23,"createdAt":9,"pushedAt":9,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":15,"starSnapshotCount":15,"syncStatus":33,"lastSyncTime":34,"discoverSource":35},6681,"Moya","Moya\u002FMoya","Network abstraction layer written in Swift.","https:\u002F\u002Fmoya.github.io",null,"Swift",15367,2004,240,157,0,1,3,8,74.21,"MIT License",false,"master",[24,25,26,27,28,29],"alamofire","hacktoberfest","networking","reactiveswift","rxswift","swift","2026-06-12 04:00:30","\u003Cp align=\"center\">\n  \u003Cimg height=\"160\" src=\"web\u002Flogo_github.png\" \u002F>\n\u003C\u002Fp>\n\n# Moya 15.0.0\n\n[![CircleCI](https:\u002F\u002Fimg.shields.io\u002Fcircleci\u002Fproject\u002Fgithub\u002FMoya\u002FMoya\u002Fmaster.svg)](https:\u002F\u002Fcircleci.com\u002Fgh\u002FMoya\u002FMoya\u002Ftree\u002Fmaster)\n[![codecov.io](https:\u002F\u002Fcodecov.io\u002Fgithub\u002FMoya\u002FMoya\u002Fcoverage.svg?branch=master)](https:\u002F\u002Fcodecov.io\u002Fgithub\u002FMoya\u002FMoya?branch=master)\n[![Carthage compatible](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FCarthage-compatible-4BC51D.svg?style=flat)](https:\u002F\u002Fgithub.com\u002FCarthage\u002FCarthage)\n[![Accio supported](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FAccio-supported-0A7CF5.svg?style=flat)](https:\u002F\u002Fgithub.com\u002FJamitLabs\u002FAccio)\n[![CocoaPods compatible](https:\u002F\u002Fimg.shields.io\u002Fcocoapods\u002Fv\u002FMoya.svg)](https:\u002F\u002Fcocoapods.org\u002Fpods\u002FMoya)\n[![Swift Package Manager compatible](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift%20Package%20Manager-compatible-brightgreen.svg)](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-package-manager)\n\n*A Chinese version of this document can be found [here](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002FReadme_CN.md).*\n\nYou're a smart developer. You probably use [Alamofire](https:\u002F\u002Fgithub.com\u002FAlamofire\u002FAlamofire) to abstract away access to\n`URLSession` and all those nasty details you don't really care about. But then,\nlike lots of smart developers, you write ad hoc network abstraction layers. They\nare probably called \"APIManager\" or \"NetworkModel\", and they always end in tears.\n\n![Moya Overview](web\u002Fdiagram.png)\n\nAd hoc network layers are common in iOS apps. They're bad for a few reasons:\n\n- Makes it hard to write new apps (\"where do I begin?\")\n- Makes it hard to maintain existing apps (\"oh my god, this mess...\")\n- Makes it hard to write unit tests (\"how do I do this again?\")\n\nSo the basic idea of Moya is that we want some network abstraction layer that\nsufficiently encapsulates actually calling Alamofire directly. It should be simple\nenough that common things are easy, but comprehensive enough that complicated things\nare also easy.\n\n> If you use Alamofire to abstract away `URLSession`, why not use something\nto abstract away the nitty gritty of URLs, parameters, etc?\n\nSome awesome features of Moya:\n\n- Compile-time checking for correct API endpoint accesses.\n- Lets you define a clear usage of different endpoints with associated enum values.\n- Treats test stubs as first-class citizens so unit testing is super-easy.\n\nYou can check out more about the project direction in the [vision document](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002FVision.md).\n\n## Sample Projects\n\nWe have provided two sample projects in the repository. To use it download the repo, run `carthage update` to download the required libraries and  open [Moya.xcodeproj](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Ftree\u002Fmaster\u002FMoya.xcodeproj). You'll see two schemes: `Basic` and `Multi-Target` - select one and then build & run! Source files for these are in the `Examples` directory in project navigator. Have fun!\n\n## Project Status\n\nThis project is actively under development, and is being used in [Artsy's auction app](https:\u002F\u002Fgithub.com\u002FArtsy\u002Feidolon). We consider it ready for production use.\n\n## Installation\n\n### Moya version vs Swift version.\n\nBelow is a table that shows which version of Moya you should use for\nyour Swift version.\n\n| Swift  | Moya           | RxMoya          | ReactiveMoya   | RxSwift        | ReactiveSwift  | Alamofire      |\n| -----  | -------------- |---------------- |--------------- |--------------- |--------------- |--------------- |\n| >= 5.2 | >= 15.0.0      | >= 15.0.0       | >= 15.0.0      | 6.X            | 6.X            | 5.X            |\n| 5.X    | >= 14.0.0      | >= 14.0.0       | >= 14.0.0      | 5.X            | 6.X            | 5.X            |\n| 5.X    | >= 13.0.0      | >= 13.0.0       | >= 13.0.0      | 4.X            | 5.X            | >= 4.1         |\n| 4.X    | 9.0.0 - 12.0.1 | 10.0.0 - 12.0.1 | 9.0.0 - 12.0.1 | 4.X(>= 10.0.0) | 4.X(>= 12.0.0) | 4.1(>= 11.0.0) |\n| 3.X    | 8.0.0 - 8.0.5  | 8.0.0 - 8.0.5   | 8.0.0 - 8.0.5  |       -        |       -        |       -        |\n| 2.3    | 7.0.2 - 7.0.4  | 7.0.2 - 7.0.4   | 7.0.2 - 7.0.4  |       -        |       -        |       -        |\n| 2.2    | \u003C= 7.0.1       | \u003C= 7.0.1        | \u003C= 7.0.1       |       -        |       -        |       -        |\n\n_Note: If you are using Swift 4.2 in your project, but you are using Xcode 10.2, Moya 13 should work correctly even though we use Swift 5.0._\n\n**Upgrading to a new major version of Moya? Check out our [migration guides](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002Fdocs\u002FMigrationGuides).**\n\n### Swift Package Manager\n\n_Note: Instructions below are for using **SwiftPM** without the Xcode UI. It's the easiest to go to your Project Settings -> Swift Packages and add Moya from there._\n\nTo integrate using Apple's Swift package manager, without Xcode integration, add the following as a dependency to your `Package.swift`:\n\n```swift\n.package(url: \"https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya.git\", .upToNextMajor(from: \"15.0.0\"))\n```\n\nand then specify `\"Moya\"` as a dependency of the Target in which you wish to use Moya.\nIf you want to use reactive extensions, add also `\"ReactiveMoya\"`, `\"RxMoya\"` or\n`\"CombineMoya\"` as your target dependency respectively.\nHere's an example `PackageDescription`:\n\n```swift\n\u002F\u002F swift-tools-version:5.3\nimport PackageDescription\n\nlet package = Package(\n    name: \"MyPackage\",\n    products: [\n        .library(\n            name: \"MyPackage\",\n            targets: [\"MyPackage\"]),\n    ],\n    dependencies: [\n        .package(url: \"https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya.git\", .upToNextMajor(from: \"15.0.0\"))\n    ],\n    targets: [\n        .target(\n            name: \"MyPackage\",\n            dependencies: [\"ReactiveMoya\"])\n    ]\n)\n```\n\nCombine note: if you're using **CombineMoya**, make sure that you use Xcode 11.5.0 \nor later. With earlier versions of Xcode you will have to manually add Combine as\na weakly linked framework to your application target.\n\n### Accio\n\n[Accio](https:\u002F\u002Fgithub.com\u002FJamitLabs\u002FAccio) is a dependency manager based on SwiftPM which can build frameworks for iOS\u002FmacOS\u002FtvOS\u002FwatchOS. Therefore the integration steps of Moya are exactly the same as described above. Once your `Package.swift` file is configured, run `accio update` instead of `swift package update`.\n\n### CocoaPods\n\nFor Moya, use the following entry in your Podfile:\n\n```rb\npod 'Moya', '~> 15.0'\n\n# or \n\npod 'Moya\u002FRxSwift', '~> 15.0'\n\n# or\n\npod 'Moya\u002FReactiveSwift', '~> 15.0'\n\n# or\n\npod 'Moya\u002FCombine', '~> 15.0'\n```\n\nThen run `pod install`.\n\nIn any file you'd like to use Moya in, don't forget to\nimport the framework with `import Moya`.\n\n### Carthage\n\nCarthage users can point to this repository and use whichever\ngenerated framework they'd like, `Moya`, `RxMoya`, `ReactiveMoya`, or\n`CombineMoya`.\n\nMake the following entry in your Cartfile:\n\n```\ngithub \"Moya\u002FMoya\" ~> 15.0\n```\n\nThen run `carthage update --use-xcframeworks`.\n\nIf this is your first time using Carthage in the project, you'll need to go through some additional steps as explained [over at Carthage](https:\u002F\u002Fgithub.com\u002FCarthage\u002FCarthage#adding-frameworks-to-an-application).\n\n> NOTE: At this time, Carthage does not provide a way to build only specific repository submodules. All submodules and their dependencies will be built with the above command. However, you don't need to copy frameworks you aren't using into your project. For instance, if you aren't using `ReactiveSwift`, feel free to delete that framework along with `ReactiveMoya` from the Carthage Build directory after `carthage update` completes. Or if you are using `ReactiveSwift` but not `RxSwift` or `Combine`, then `RxMoya`, `RxTest`, `RxCocoa`, `CombineMoya` etc. can safely be deleted.\n\n### Manually\n\n- Open up Terminal, `cd` into your top-level project directory, and run the following command *if* your project is not initialized as a git repository:\n\n```bash\n$ git init\n```\n\n- Add Alamofire & Moya as a git [submodule](http:\u002F\u002Fgit-scm.com\u002Fdocs\u002Fgit-submodule) by running the following commands:\n\n```bash\n$ git submodule add https:\u002F\u002Fgithub.com\u002FAlamofire\u002FAlamofire.git\n$ git submodule add https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya.git\n```\n\n- Open the new `Alamofire` folder, and drag the `Alamofire.xcodeproj` into the Project Navigator of your application's Xcode project. Do the same with the `Moya.xcodeproj` in the `Moya` folder.\n\n> They should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.\n\n- Verify that the deployment targets of the `xcodeproj`s match that of your application target in the Project Navigator.\n- Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the \"Targets\" heading in the sidebar.\n- In the tab bar at the top of that window, open the \"General\" panel.\n- Click on the `+` button under the \"Embedded Binaries\" section.\n- You will see two different `Alamofire.xcodeproj` folders each with two different versions of the `Alamofire.framework` nested inside a `Products` folder.\n\n> It does not matter which `Products` folder you choose from, but it does matter whether you choose the top or bottom `Alamofire.framework`.\n\n- Select the top `Alamofire.framework` for iOS and the bottom one for macOS.\n\n> You can verify which one you selected by inspecting the build log for your project. The build target for `Alamofire` will be listed as either `Alamofire iOS`, `Alamofire macOS`, `Alamofire tvOS` or `Alamofire watchOS`.\n\n- Click on the `+` button under \"Embedded Binaries\" again and add the correct build target for `Moya`.\n\n- And that's it!\n\n> The three frameworks are automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.\n\n## Usage\n\nAfter [some setup](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002Fdocs\u002FExamples\u002FBasic.md), using Moya is really simple. You can access an API like this:\n\n```swift\nprovider = MoyaProvider\u003CGitHub>()\nprovider.request(.zen) { result in\n    switch result {\n    case let .success(moyaResponse):\n        let data = moyaResponse.data\n        let statusCode = moyaResponse.statusCode\n        \u002F\u002F do something with the response data or statusCode\n    case let .failure(error):\n        \u002F\u002F this means there was a network failure - either the request\n        \u002F\u002F wasn't sent (connectivity), or no response was received (server\n        \u002F\u002F timed out).  If the server responds with a 4xx or 5xx error, that\n        \u002F\u002F will be sent as a \".success\"-ful response.\n    }\n}\n```\n\nThat's a basic example. Many API requests need parameters. Moya encodes these\ninto the enum you use to access the endpoint, like this:\n\n```swift\nprovider = MoyaProvider\u003CGitHub>()\nprovider.request(.userProfile(\"ashfurrow\")) { result in\n    \u002F\u002F do something with the result\n}\n```\n\nNo more typos in URLs. No more missing parameter values. No more messing with\nparameter encoding.\n\nFor more examples, see the [documentation](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002Fdocs\u002FExamples).\n\n## Reactive Extensions\n\nEven cooler are the reactive extensions. Moya provides reactive extensions for\n[ReactiveSwift](https:\u002F\u002Fgithub.com\u002FReactiveCocoa\u002FReactiveSwift),\n[RxSwift](https:\u002F\u002Fgithub.com\u002FReactiveX\u002FRxSwift), and \n[Combine](https:\u002F\u002Fdeveloper.apple.com\u002Fdocumentation\u002Fcombine).\n\n### ReactiveSwift\n\n[`ReactiveSwift` extension](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002Fdocs\u002FReactiveSwift.md) provides both `reactive.request(:callbackQueue:)` and \n`reactive.requestWithProgress(:callbackQueue:)` methods that immediately return\n`SignalProducer`s that you can start, bind, map, or whatever you want to do.\nTo handle errors, for instance, we could do the following:\n\n```swift\nprovider = MoyaProvider\u003CGitHub>()\nprovider.reactive.request(.userProfile(\"ashfurrow\")).start { event in\n    switch event {\n    case let .value(response):\n        image = UIImage(data: response.data)\n    case let .failed(error):\n        print(error)\n    default:\n        break\n    }\n}\n```\n\n### RxSwift\n\n[`RxSwift` extension](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002Fdocs\u002FRxSwift.md) also provide both `rx.request(:callbackQueue:)` and\n`rx.requestWithProgress(:callbackQueue:)` methods, but return type is\ndifferent for both. In case of a normal `rx.request(:callbackQueue)`, the\nreturn type is `Single\u003CResponse>` which emits either single element or an\nerror. In case of a `rx.requestWithProgress(:callbackQueue:)`, the return \ntype is `Observable\u003CProgressResponse>`, since we may get multiple events\nfrom progress and one last event which is a response.\n\nTo handle errors, for instance, we could do the following:\n\n```swift\nprovider = MoyaProvider\u003CGitHub>()\nprovider.rx.request(.userProfile(\"ashfurrow\")).subscribe { event in\n    switch event {\n    case let .success(response):\n        image = UIImage(data: response.data)\n    case let .error(error):\n        print(error)\n    }\n}\n```\n\nIn addition to the option of using signals instead of callback blocks, there are\nalso a series of signal operators for RxSwift and ReactiveSwift that will attempt\nto map the data received from the network response into either an image, some JSON,\nor a string, with `mapImage()`, `mapJSON()`, and `mapString()`, respectively. If the mapping is unsuccessful, you'll get an error on the signal. You also get handy methods\nfor filtering out certain status codes. This means that you can place your code for\nhandling API errors like 400's in the same places as code for handling invalid\nresponses.\n\n### Combine\n\n`Combine` extension provides `requestPublisher(:callbackQueue:)` and\n`requestWithProgressPublisher(:callbackQueue)` returning \n`AnyPublisher\u003CResponse, MoyaError>` and `AnyPublisher\u003CProgressResponse, MoyaError>`\nrespectively.\n\nHere's an example of `requestPublisher` usage:\n\n```swift\nprovider = MoyaProvider\u003CGitHub>()\nlet cancellable = provider.requestPublisher(.userProfile(\"ashfurrow\"))\n    .sink(receiveCompletion: { completion in\n        guard case let .failure(error) = completion else { return }\n\n        print(error)\n    }, receiveValue: { response in\n        image = UIImage(data: response.data)\n    })\n```\n\n## Community Projects\n\n[Moya has a great community around it and some people have created some very helpful extensions](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002Fdocs\u002FCommunityProjects.md).\n\n## Contributing\n\nHey! Do you like Moya? Awesome! We could actually really use your help!\n\nOpen source isn't just writing code. Moya could use your help with any of the\nfollowing:\n\n- Finding (and reporting!) bugs.\n- New feature suggestions.\n- Answering questions on issues.\n- Documentation improvements.\n- Reviewing pull requests.\n- Helping to manage issue priorities.\n- Fixing bugs\u002Fnew features.\n\nIf any of that sounds cool to you, send a pull request! After your first\ncontribution, we will add you as a member to the repo so you can merge pull\nrequests and help steer the ship :ship: You can read more details about that [in our contributor guidelines](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002FContributing.md).\n\nMoya's community has a tremendous positive energy, and the maintainers are committed to keeping things awesome. Like [in the CocoaPods community](https:\u002F\u002Fgithub.com\u002FCocoaPods\u002FCocoaPods\u002Fwiki\u002FCommunication-&-Design-Rules), always assume positive intent. Even if a comment sounds mean-spirited, give the person the benefit of the doubt.\n\nPlease note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by [its terms](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002FCode%20of%20Conduct.md).\n\n### Adding new source files\n\nIf you add or remove a source file from Moya, a corresponding change needs to be made to the `Moya.xcodeproj` project at the root of this repository. This project is used for Carthage. Don't worry, you'll get an automated warning when submitting a pull request if you forget.\n\n### Help us improve Moya documentation\n\nWhether you’re a core member or a user trying it out for the first time, you can make a valuable contribution to Moya by improving the documentation. Help us by:\n\n- Sending us feedback about something you thought was confusing or simply missing.\n- Suggesting better wording or ways of explaining certain topics.\n- Sending us a pull request via GitHub.\n- Improving the [Chinese documentation](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002FReadme_CN.md).\n\n\n## License\n\nMoya is released under an MIT license. See [License.md](https:\u002F\u002Fgithub.com\u002FMoya\u002FMoya\u002Fblob\u002Fmaster\u002FLicense.md) for more information.\n","Moya是一个用Swift编写的网络抽象层。它通过封装Alamofire来简化网络请求处理，支持编译时检查API端点访问的正确性，并允许开发者通过枚举值清晰地定义不同端点的使用方式，同时将测试桩视为一等公民以简化单元测试。适用于iOS应用开发中需要构建稳定、可维护且易于测试的网络层场景。项目遵循MIT许可证，拥有广泛的社区支持和活跃的开发状态。",2,"2026-06-11 03:08:18","top_language"]