Swift Macros have brought in a new wave of possibilities. The aim of this project is to curate a list of community-created Macros and associated learning resources.
A lot of use-cases my Sourcery covered before can now be implemented by Swift Macros.
- Swift AST Explorer
- This is extremely helpful when working with SwiftSyntax, I used this when writing Sourcery parser and you can leverage it to build your own Macros.
Dive into Swift Macros with these WWDC sessions:
- Write Swift Macros: An introductory session on Macros, their roles, and workings with a basic example.
- Expand Swift Macros: A deeper exploration into crafting your Macros and testing their functionality.
- Example Swift Macros: Check out real-world examples from Apple, like
@AddCompletionHandler
and@AddAsync
.
- Swift Macros by SwiftLee
- Antoine goes over the introduction of what Macros are and how you can build your own one with an example.
- How to Create Swift Macros in Xcode 15
- Francesco goes over creating your first macro with testing and some interesting tidbits.
- EnvironmentValues & EnvironmentValue: Bypass boilerplate code and swiftly support new SwiftUI Environment Keys and Values.
- Coding Keys: Effortlessly generate CodingKeys for converting
snake_case
tolowerCamelCase
. - Builder pattern: Apply the Builder Pattern with ease by generating a
Builder
helper class, mimicking stored properties of the associated struct.
Take part in this exciting evolution in Swift. Your contributions are most welcome!