Swiggy Kumar Reddy Jun 7, 2022

Advanced Techniques to Speed Up Compile Time in Xcode

Article Summary

Swiggy's iOS team was watching Xcode compile for minutes after single-line changes. They cut that time by 75%.

Kumar Reddy from Swiggy breaks down the Xcode build system from preprocessor to loader, then shares two phases of optimization: one-time build settings and ongoing dependency management. This isn't theory: it's battle-tested techniques from a production app.

Key Takeaways

Critical Insight

Swiggy reduced clean build time from 300 to 250 seconds and incremental builds by up to 75% through build settings optimization and restructuring Swift dependency graphs.

The article reveals three compiler rules that explain why your incremental builds are slower than they should be.

About This Article

Problem

iOS developers were stuck with slow incremental builds. Swift recompiles all dependent files whenever you add a new function, struct, or extension to a single file. This creates a cascading effect across the codebase.

Solution

Kumar Reddy's team split their monolithic utility and extension files into separate files, each focused on one extension type. This let the Swift dependency graph compile only the affected files instead of the entire dependent chain.

Impact

After restructuring, changing a single line in a utility file now compiles 3 files instead of 30. Better code organization cuts incremental build times without needing compiler flag changes.