Improving Swift Compilation Times from 12 to 2 Minutes
Article Summary
Zalando's iOS team was bleeding 12 minutes per build. That's not just annoying, it's expensive.
The Zalando engineering team tackled their growing Swift compilation problem as their Fleek app expanded. A simple Xcode configuration change delivered dramatic results without sacrificing debuggability.
Key Takeaways
- Reduced clean build time from 12 minutes to 2.5 minutes (83% improvement)
- Enabled Whole Module Optimization in Debug without the optimization flag
- Saved 26 hours of daily compilation time across the team
- Used custom SWIFT_WHOLE_MODULE_OPTIMIZATION flag as User-Defined Setting
A single Xcode build setting change cut compilation time by 80% and saved the equivalent of three full-time developers daily.
About This Article
Developers working on Zalando's Fleek app had to wait about 1 minute every time they changed a single file and recompiled it incrementally. This slowed down their work and made the development process frustrating.
Instead of working within Xcode's built-in options, the team created a custom User-Defined Build Setting called SWIFT_WHOLE_MODULE_OPTIMIZATION and set it to YES. They kept the Optimization Level at None. This let them use whole module optimization without the -O flag, which normally prevents debugging.
When a developer changed a file that most of the app depends on, compilation dropped to 1 minute instead of taking the full recompilation time. Across the iOS team's 20 daily builds, this saved about 26 hours of compilation time each day.