Macros in Swift are this 12 months’s massive language function. I’m certain you’ve already watched the superb Write Swift macros and Broaden on Swift macros WWDC session movies, however what comes after that?
We instantly put them in our manufacturing code and hope for the perfect, proper? 😬
I wrote one thing comparable when Swift 5.4 launched outcome builders, and we noticed a proliferation of experiments. Now we’re in that very same interval with macros.
The bundle index is already filling up with packages that include macros, and it makes me glad we added 5.9 help so shortly. Among the packages I’m linking to under will turn out to be important elements of the Swift bundle ecosystem, and a few will stay experiments. It’s unattainable to know which but!
There’s all the pieces from full-featured packages like SwiftRequest and papyrus that allow you to outline a type-safe HTTP consumer with perform annotations to smaller utility packages like AssociatedObject, which permits variable storage in extensions. There are numerous, many extra although. Right here’s a listing of others I noticed this week:
There’s one other benefit of getting these packages out there as open-source. They’re academic sources, too! Are you interested in the way you may wish to use macros in your apps? Have a look by the supply of among the packages linked above. I’m certain you’ll be taught one thing.