Swiftpack.co - Package - Ryucoin/NetworkUtils

NetworkUtils

Swift package for handling HTTP requests

Version License Platform

Author

WyattMufson - cofounder of Ryu Blockchain Technologies

Overview

NetworkUtils is a package for implementing HTTP network requests in Swift for iOS. The goal of the project is to replicate the funcitonality of the axios npm package used in nodejs.

It is built off of the Foundation URL Loading System (similar to Alamofire). NetworkUtils uses Google's Promises library for promise support.

Installation

NetworkUtils is available through CocoaPods. To install it, simply add the following lines to your Podfile:

pod 'NetworkUtils'

And run pod install.

Example Usage

HTTP Requests

let networkUtils = NetworkUtils.main

networkUtils.get("http://ip-api.com/json").then {(data) in
    print("Data found: \(data)")
}.catch {(error) in
    print("Error: \(error.localizedDescription)")
}

Reachability

let reachability = NetworkUtils.reachability

switch reachability.connection {
case .wifi:
    print("Reachable via WiFi")
case .cellular:
    print("Reachable via Cellular")
case .none:
    print("Not Reachable")
}

Testing

NetworkUtils uses fastlane for testing automation. Run the tests with:

fastlane tests

Updating the Pod

pod trunk push NetworkUtils.podspec

Github

link
Stars: 5
Help us keep the lights on

Dependencies

Used By

Total: 0