Macros in Swift are this year’s big language feature. I’m sure you’ve already watched the excellent Write Swift macros and Expand on Swift macros WWDC session videos, but what comes after that?

We immediately put them in our production code and hope for the best, right? 😬

I wrote something similar when Swift 5.4 introduced result builders, and we saw a proliferation of experiments. Now we’re in that same period with macros.

The package index is already filling up with packages that contain macros, and it makes me glad we added 5.9 support so quickly. Some of the packages I’m linking to below will become essential parts of the Swift package ecosystem, and some will remain experiments. It’s impossible to know which yet!

There’s everything from full-featured packages like SwiftRequest and papyrus that let you define a type-safe HTTP client with function annotations to smaller utility packages like AssociatedObject, which allows variable storage in extensions. There are many, many more though. Here’s a list of others I saw this week:

There’s another advantage of having these packages available as open-source. They are educational resources, too! Are you curious about how you might want to use macros in your apps? Take a look through the source of some of the packages linked above. I’m sure you’ll learn something.

Dave Verwer  





iPad Software Engineer @ Liquid Instruments – Liquid Instruments is a startup creating a range of modern test and measurement devices using reconfigurable FPGA hardware. We're looking for someone to help develop the beautiful iPad user interface that drives it all. – On-site (Australia)


And finally...

I said “but Craig uses it!” 💥