Swiftpack.co - Package - Mumble-SRL/MBNetworkingSwift

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

Mumble-SRL/MBNetworkingSwift

Simple HTTP Networking in Swift

MBurger Logo

Documentation CocoaPods Carthage Compatible License

MBNetworking

Networking library written in Swift used in MBurger and other Mumble projects.

Installation

Swift Package Manager

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

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

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"

Manually

Copy and paste the content of the MBNetworking folder in your project

Usage

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)
                        }
}

Github

link
Stars: 0
Last commit: 1 week ago