How we used Macros to Promote MVVM architecture adoption
Article Summary
Duolingo's iOS team turned a boilerplate problem into a Swift Macros showcase. Their codebase grew, but developer friction didn't have to.
As Duolingo's iOS team scaled, they standardized on MVVM architecture but hit a wall with repetitive DataSource code. Carter Levin shares how they used Swift Macros to generate boilerplate automatically while keeping build times in check.
Key Takeaways
- 4,300 lines of code now auto-generated, never written, reviewed, or tested
- Macros operate on AST at compile time, fully integrated into Swift compiler
- Manual binary linking via S3 cache avoided 10-20 second build time hits
- DataSources were ideal: consistent patterns but hard to abstract with generics
- Generated code is standardized, tested, and less prone to manual errors
Critical Insight
Duolingo eliminated 4,300+ lines of repetitive DataSource code using Swift Macros, saving engineering time while improving code quality and consistency.