Swiftpack.co - rhysforyou/Superhighway as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by rhysforyou.
rhysforyou/Superhighway 1.0.0
As big a networking library as you'll need
⭐️ 13
🕓 2 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/rhysforyou/Superhighway.git", from: "1.0.0")


Build & Test Swift Package Swift Package Manager Recommended Supports macOS, iOS, tvOS, watchOS, and Linux Licensed under the Unlicense

Superhighway is a networking library heavily inspired by tiny-networking. It defines an Endpoint type which encapsulates the relationship between a URLRequest and the Decodable entity it represents.

A Simple Example

struct Repository: Decodable {
    let id: Int64
    let name: String

func getRepository(author: String, name: String) -> Endpoint<Repository> {
    return Endpoint(json: .get, url: URL(string: "https://api.github.com/repos/\(author)/\(name)")!)

let endpoint = getRepository(author: "rhysforyou", name: "Superhighway")

This simply gives us the description of an endpoint, to actually load it, we can pass it to a URLSession:

do {
    let (repository, _) = try await URLSession.default.data(for: endpoint)
    print("Repository: \(repository)")
} catch {
    print("Error: \(error)")

If the task is cancelled before it finishes, any networking operations will be halted.


The recommended way to use Superhighway is through the Swift Package manager. For Xcode projects, simply add this repository to the project's Swift packages list. For projects using a Package.swift file, add the following:

// swift-tools-version:5.5
import PackageDescription

let package = Package(
    // ...
    dependencies: [
        .package(url: "https://github.com/rhysforyou/Superhighway.git", "0.5.0"..<"0.6.0")
    targets: [
            name: "MyTarget",
            dependencies: ["Superhighway"])

Other package managers such as CocoaPods and Carthage are officially unsupported, but this entire library is encapsulated in a single Endpoint.swift file which can be copied into an existing project and used as-is.


Stars: 13
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

2 weeks ago
  • First stable release

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