Simple abstraction for URLComponents for ease to use
CocoaPods
For URLBuilder, use the following entry in your Podfile:
pod 'URLBuilder', '~> 1.0'
Then run pod install
.
SwiftPM (Accio)
For install URLBuilder with Accio (or SwiftPM from Xcode 11) add this line to Package.swift
.package(url: "https://github.com/ephedra-software/URLBuilder.git", .upToNextMajor(from: "1.0"))
Then run accio install
or accio update
.
In any file you'd like to use URLBuilder in, don't forget to
import the framework with import URLBuilder
.
Usage
Using URLBuilder is really simple. You can access an API like this:
let url = URLBuilder
.scheme(.https)
.user(custom: "john.doe")
.host(custom: "www.example.com")
.port(custom: 123)
.path(custom: "/forum/questions")
.query(items: ("tag", "networking"), ("order", "order"))
.fragment(custom: "top")
.url
print(url ?? "nil") // https://[email protected]:123/forum/questions?tag=networking&order=order#top
This is a very simple example. Don't do that
License
URLBuilder is released under an MIT license. See LICENSE for more information.