Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 1.68 KB

README.md

File metadata and controls

57 lines (42 loc) · 1.68 KB

Awesome Swift Macros

A hand-curated list of Swift macros. Feel free to contribute!

WWDC23

Macros

// "Stringify" macro turns the expression into a string.
#stringify(x + y)

// "AddBlocker" complains about addition operations. We emit a warning
// so it doesn't block compilation.
#addBlocker(x * y + z)

// "#URL" macro provides compile time checked URL construction. If the URL is
// malformed an error is emitted. Otherwise a non-optional URL is expanded.
#URL("https://swift.org/")
#powerAssert(max(a, b) == c)
             |   |  |  |  |
             7   4  7  |  12
                       false
  • Preview macro (Xcode 15+)
#Preview {
    Button("SwiftUI") {}
}
import SFSymbolsMacro
import SwiftUI

@SFSymbol
enum Symbols: String { ... }

Proposals