Swiftpack.co - rosberry/Networking-iOS as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by rosberry.
rosberry/Networking-iOS 1.1.1
Lightweight framework for working with network layer based on URLSession.
⭐️ 1
🕓 3 years ago
.package(url: "https://github.com/rosberry/Networking-iOS.git", from: "1.1.1")

Networking

Swift Version Carthage Compatible Swift Package Manager

Requirements

  • iOS 11.0+
  • Xcode 11.0+

Installation

Depo

Depo is a universal dependency manager that combines Carthage, SPM and CocoaPods and provides common user interface to all of them.

To install Networking via Carthage using Depo you need to add this to your Depofile:

carts:
  - kind: github
    identifier: rosberry/Networking-iOS
To install Networking via SPM or CocoaPods

Via SPM

Add this to your Depofile:

swiftPackages:
  - name: Networking-iOS
    url: https://github.com/rosberry/Networking-iOS.git
    version:
      operation: upToNextMajor
      value: 1.0.0

Via CocoaPods

Add this to your Depofile:

pods:
  - name: Networking

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Networking into your Xcode project using Carthage, specify it in your Cartfile:

github "rosberry/Networking-iOS"

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Networking into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Networking'

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Once you have your Swift package set up, adding Networking as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/rosberry/Networking-iOS.git", .upToNextMajor(from: "1.0.0"))
]

Documentation

Lightweight framework for working with network layer based on URLSession.

Features:

  • making requests with Endpoint
  • error handling proxy
  • decode/encode
  • auto task canceling for similar requests
  • default http headers

Usage

Create your own Endpoint

import Foundation
import Networking

enum JokesEndpoint: Endpoint {

    case random(category: String)

    var baseURL: URL {
        URL(string: "https://official-joke-api.appspot.com/jokes")!
    }

    var path: String {
        "random"
    }
}

Use RequestService to execute request with endpoint

import Foundation
import Networking

final class JokesServiceImp: RequestService, JokesService {

    private init() {
        super.init()
        decoder.keyDecodingStrategy = .convertFromSnakeCase
    }

    func loadRandomJoke(category: String, completion: @escaping ResultCompletion<Joke>) {
        request(JokesEndpoint.random(category: category)) { result in
            completion(result)
        }
    }
}

About

This project is owned and maintained by Rosberry. We build mobile apps for users worldwide 🌏.

Check out our open source projects, read our blog or give us a high-five on 🐦 @rosberryapps.

License

This project is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 1
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Networking 1.1.1
3 years ago

Fix carthage build

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics