Networking library written in Swift used in MBurger and other Mumble projects.
With Xcode 11 you can start using Swift Package Manager to add MBNetworkingSwift to your project. Follow those simple steps:
- In Xcode go to File > Swift Packages > Add Package Dependency.
- Enter
https://github.com/Mumble-SRL/MBNetworkingSwift.git
in the "Choose Package Repository" dialog and press Next. - Specify the version using rule "Up to Next Major" with "1.0.6" as its earliest version and press Next.
- Xcode will try to resolving the version, after this, you can choose the
MBNetworkingSwift
library and add it to your app target.
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate MBNetworkingSwift into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'MBNetworkingSwift'
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate MBNetworkingSwift into your Xcode project using Carthage, specify it in your Cartfile:
github "Mumble-SRL/MBNetworkingSwift"
Copy and paste the content of the MBNetworking folder in your project
Example usage:
let urlString = "https://www.example.com/api/test"
let headers = [HTTPHeader(field: "Accept", value: "application/json")]
let parameters = ["key": "value"]
MBNetworking.request(withUrl: urlString,
method: .get,
headers: headers,
parameters: parameters,
encoding: URLParameterEncoder.default) { response in
switch response.result {
case .success(let json):
print(json)
case .error(let error):
print(error.localizedDescription)
}
}