davidsteppenbeck / URL

A Swift macro that provides an unwrapped URL from a string literal.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

URL

URL is a freestanding Swift macro that provides an unwrapped Foundation URL for the string literal argument. The macro checks the validity of the literal and throws an error if it does not represent a valid Foundation URL.

Usage

import URL

let url = #URL("https://www.apple.com")

This will automatically generate the following code:

URL(string: "https://www.apple.com")!

Installation

The package can be installed using Swift Package Manager. To add URL to your Xcode project, select File > Add Package Dependancies... and search for the repository URL: https://github.com/davidsteppenbeck/URL.git.

License

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

Acknowledgements

The URL macro example is described in detail in Antoine v.d. Lee's blog post.

About

A Swift macro that provides an unwrapped URL from a string literal.

License:MIT License


Languages

Language:Swift 100.0%