Sitemap

Member-only story

Factory: Macro Misadventures

Why adding Swift Macros to Factory is a study in compromise.

8 min readMay 30, 2025
Factory Logo, @2025, Michael Long

One of the new features added to Xcode last year was Swift Macros, expressions or attributes one could add to code that expand at compile time, adding features and reducing boilerplate and enabling complex behaviors without the need for manual scaffolding.

One of the better-known examples of this was @Observable, which automatically synthesized the plumbing needed for Swift’s new Observation framework.

Observable was a feature touted to save developers from writing mountains of mindless boilerplate while increasing performance across the board… albeit with a few small problems.

This article discusses why I wanted to add macros to my dependency injection project Factory, how Factory might benefit from them, and the many, many, many trials and tribulations I’ve stumbled into along the way trying to implement the silly things.

And as an experiment and in keeping with the modern age, I also leaned heavily on generative AI systems in an attempt to speed my progress along.

And let’s just say the results there were mixed as well.

But more on that later.

Let’s dig it, shall we?

Factory’s Current…

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

Responses (2)