Swiftpack.co - Package - Chandlerdea/NetworkingController


This is a simple, lightweight library for making asynchronous network requests on iOS. It is thread safe, meaning that networking requests can be made from any thread, without the dangers of the common pitfalls found in multi threaded environments.


This is written in Swift 4, works with macOS, iOS, watchOS, and tvOS.


You can install this library with Carthage, Cocoapods, or Swift's package manager


Add this line to you Cartfile:

github "Chandlerdea/NetworkingController"

Run carthage update and then add the created framework in $(SRCROOT)/Carthage/build/iOS to the Embedded Binaries section of you project.


I'm having trouble linting the cocoapod, so cocoapods support isn't available just yet. I'll be adding it as soon as I figure out the issue.

Swift Package Manager

In your Packages.swift file, add this code

import PackageDescription

let package = Package(
    url: "https://github.com/Chandlerdea/NetworkingController/NetworkingController.swift"
    majorVersion: 1

How to Use

Using the library is pretty simple. The NetworkingController is given a URLRequest to perform, and gives its delegates the data returned from the request. There is only one public function, perform(request:), and successDelegate and errorDelegate properties. A typical use looks like this:

class Foo {

  private lazy var controller: NetworkingController = {
    let controller: NetworkingController = NetworkingController()
    controller.successDelegate = self
    controller.errorDelegate = self
    return controller

  func doStuff() {
    let url: URL = URL(string: "http://www.google.com")!
    let request: URLRequest = URLRequest(url: url)
    self.controller.perform(request: request)

extension Foo: NetworkingControllerErrorDelegate {

  func requestDidFail(_ request: URLRequest, error: NSError, status: URLResponseStatus?) {


  func sessionDidFail(_ error: NSError?) {


extension Foo: NetworkingControllerSuccessDelegate {

  func requestDidComplete(_ request: URLRequest, data: Data) {



This library handles certificate pinning out of the box. All you need to do is provide the certificates, and the library will handle the authentication challenge correctly. For HTTP basic authentication, there is a function on NetworkingControllerAuthenticationDelegate:

func requestDidReceiveAuthenticationChallenge(_ request: URLRequest) -> (username: String, password: String)?

If you implement this method, the library will handle the authentication challenge correctly. The library stores the URLCredential perminently, so this will only need to be done once per app install. If you are using HTTPS, but the endpoint your hitting doesn't require authentication, you can specify to continue with the request, which causes the URLSession to perform the request. You just need to implement this method in NetworkingControllerAuthenticationDelegate:

    func shouldProceedWithAuthenticationChallendWithoutCredentials(_ request: URLRequest) -> Bool

If you have any critiques, or ideas, open a PR or let me know!


Stars: 3
Help us keep the lights on


Used By

Total: 0


v1.2.1 - Feb 17, 2018

Fixed retain cycles

v1.2.0 - Jan 27, 2018

Added better authentication handling, and the ability to handle authentication challenges without supplying a credential, for both basic authentication and certificate pinning.

v1.1.0 - Sep 27, 2017

Added authentication handling support. Specifically, support for basic HTTP authentication and server trust.

1.0.0 - Sep 21, 2017