Skip to content

dodobrands/swift-url-macro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swift-url-macro

A Swift macro for compile-time URL validation. Replaces URL(string:)! with #URL() for safer, non-optional URLs.

Usage

import URLMacro let url = #URL("https://example.com") // Compiles to: URL(string: "https://example.com")!

Invalid URLs produce a compile-time error:

let url = #URL("not a url") // ❌ Compile error: malformed URL

Installation

Add to your Package.swift:

.package(url: "https://github.com/dodobrands/swift-url-macro", from: "1.0.0"),

Then add "URLMacro" to your target dependencies.

SwiftFormat integration

Use with the urlMacro rule:

--enable urlMacro --url-macro "#URL,URLMacro" 

License

MIT

About

Swift macro for compile-time URL validation. Replaces URL(string:)! with #URL() for safer, non-optional URLs.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages