Moya Documentation
Moya is a modern, user-friendly Swift network abstraction layer that simplifies making requests to RESTful services. Please find a detailed breakdown of the Moya Documentation below.
Getting Started
Using Moya starts by defining an “endpoint”, which is an enum that implements the “TargetType” protocol.
Installation
Moya is compatible with Swift 5.0+ and can be installed either through CocoaPods, Carthage, or Swift Package Manager.
Installation via CocoaPods
To use CocoaPods, add the following line to your Podfile:
pod 'Moya'
Installation via Carthage
To use Carthage, add the following line to your Cartfile:
github "Moya/Moya"
Installation via Swift Package Manager
For using Swift Package Manager, modify your Package.swift file to include the following:
dependencies: [ .package(url: "https://github.com/Moya/Moya.git", .upToNextMajor(from: "14.0.0")) ]
Moya Concept
One of the main aims of Moya is to use enum values to define endpoints on a web service. You might add cases to this enum for the different endpoints, e.g., GET (an endpoint), POST (another endpoint).
Configuration and Customization
Moya allows you to customize your provider with plugins. Plugins can be easily added and also created as per your requirement. Some of the popular plugins include NetworkLoggerPlugin, NetworkActivityPlugin, and CredentialsPlugin.
Troubleshooting
You can use the MoyaResponse extension to simplify this process. If you’re having trouble getting your project set up, check the list of common issues in the ‘Common issues’ section of the project’s Readme.
Contact
If you’re struggling with anything or found a bug, feel free to open a GitHub issue on the Moya repository. Also, pull requests are always welcome.