Mobile Development 11 min read

Improving iOS Build Efficiency through Componentization, Incremental Compilation, and Centralized Caching

This article describes how Ctrip's iOS team reduced build times from nearly an hour to minutes by modularizing the codebase into bundles, applying incremental compilation with CCache, optimizing header search paths, and introducing a centralized cache for faster bundle retrieval.

Ctrip Technology
Ctrip Technology
Ctrip Technology
Improving iOS Build Efficiency through Componentization, Incremental Compilation, and Centralized Caching

Development efficiency is a perpetual concern, and for iOS the compilation speed directly impacts both development and integration testing. The original Ctrip travel app iOS project compiled the entire source tree—millions of lines of code—in almost an hour, causing long feedback loops for developers and testers.

Background : The monolithic build required full‑source compilation for every change, leading to wasted time when a single commit introduced errors only after a lengthy build.

1. Project Componentization : The codebase was split into independent sub‑projects (Bundles), each producing a static library and resource package. Developers compile only the bundle they work on, while other bundles are linked as pre‑built libraries, dramatically shortening local build times.

2. Incremental Compilation : To further speed up CI builds, the team adopted CCache to cache Xcode compilation artifacts. A custom Python script using filecmp merges only files whose contents changed, ignoring metadata changes, and configures -derivedDataPath for cache storage. Cache clearing functionality was also added to handle stale or corrupted caches.

3. Jenkins Integration : The CI pipeline (master‑slave Jenkins) was modified to retain workspaces and associate specific bundles with specific build nodes via the Label Parameter Plugin, ensuring cache hits and minimizing diff overhead.

4. Bundle Sub‑division : As business logic grew, bundles were further split by functional modules (e.g., Hotel core and Hotel base), allowing even finer‑grained compilation and reuse across independent apps.

5. Header Search Path Optimization : Public headers were exported via a dedicated include directory and a generated module.map to improve lookup speed and prepare for Swift migration.

6. Centralized Cache : A hidden .iOSBundleRepo directory stores bundle versions locally; the build system checks this cache before downloading. Different cache eviction policies are applied for local development (longer TTL, fewer versions) and CI (short TTL, more versions). This reduced overall packaging time from 7 minutes to 5 minutes.

Results : Incremental compilation cut a typical bundle build from 116 s to 9 s, and the combined optimizations lowered full‑project build times from ~1 hour to under 10 minutes, with noticeable improvements for both developers and testers.

Problems & Reflections : No single solution solves all build‑time issues; trade‑offs include increased maintenance of exported headers and cache storage pressure. Nonetheless, the multi‑step approach satisfied current business needs while highlighting the need for ongoing monitoring and cleanup.

mobile developmentiOSbuild optimizationcachingcomponentizationIncremental Compilation
Ctrip Technology
Written by

Ctrip Technology

Official Ctrip Technology account, sharing and discussing growth.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.