artemnovichkov / awesome-swift-macros

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

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

License:MIT License