Zalando Apr 12, 2017

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

Critical Insight

A single Xcode build setting change cut compilation time by 80% and saved the equivalent of three full-time developers daily.

The fix required bypassing Xcode's UI entirely and adding a hidden build flag most developers don't know exists.

About This Article

Problem

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.

Solution

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.

Impact

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.