awesome-swift-macros
                                
                                 awesome-swift-macros copied to clipboard
                                
                                    awesome-swift-macros copied to clipboard
                            
                            
                            
                        A hand-curated list of Swift macros. Feel free to contribute!
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 { ... }