Xcode New Build System: Module Interface Caching and Run Script Boundaries
Xcode's New Build System uses .swiftinterface caching and explicit Run Script boundaries to protect incremental builds; verify with xcodebuild timing summaries.
14 Mar 2026, 02:12 UTC

The Problem: Silent Full Rebuilds from Undeclared Build Boundaries
Xcode's New Build System (default since Xcode 12) schedules work as a directed acyclic graph (DAG) instead of the legacy Make-based sequence. When a project treats scheme order as the dependency contract, downstream Swift modules and Objective-C targets rebuild even when nothing in their public API changed. The practical effect is slow local builds, flaky CI, and module-cache mismatches that only appear after a clean.
Takeaway: Declare every dependency edge explicitly, cache Swift module interfaces (.swiftinterface) per configuration, and give every Run Script phase explicit input and output file lists. Treat these declarations as the trust boundary of the build graph.
Requirements Driving the Design
- Incremental compilation at Swift module granularity across local and CI machines.
- Deterministic build-setting evaluation: project, then target, then configuration, then .xcconfig.
- Parallel execution limited by declared edges, not implicit scheme ordering.
- Visible build-phase timing so CI can reject regressions.
Smallest Suitable Design
The New Build System replaces the legacy engine with a Swift-written DAG scheduler. Each target is a graph node. Declared dependencies form edges. Xcode generates and caches .swiftinterface files per configuration in DerivedData; downstream targets consume the interface instead of recompiling upstream sources unless the public API changes. Build settings cascade in a fixed order, so an .xcconfig included at target level overrides project values without ambiguity.
Trust and Data Boundaries
A target cannot read another target's built products unless the dependency is declared in:
- Target Dependencies — establishes build order and module visibility.
- Link Binary With Libraries — supplies link-time symbols.
Run Script phases are the other boundary. A script with no declared inputs runs on every build. A script with declared inputs and outputs runs only when inputs change or outputs are missing, which preserves incrementality.
Operational Checks
1. Confirm the New Build System and Module Interface Generation
# Run in Terminal at the project root. No special permissions required.
# Replace with an actual target name.
xcodebuild -showBuildSettings -target | grep -E '(BUILD_SYSTEM|SWIFT_MODULE_INTERFACES)'
# Expected: BUILD_SYSTEM = com.apple.dt.Xcode.BuildSystem.NewBuildSystem
# Expected: SWIFT_MODULE_INTERFACES = YES
In Xcode, verify File → Project/Workspace Settings → Build System shows New Build System (Default).
2. Audit Run Script Input and Output Declarations
Open the target's Build Phases. For each Run Script phase, populate Input Files and Output Files, or set Based on dependency analysis to Yes. Scripts without these lists bypass the DAG and execute unconditionally.
3. Measure Incremental Rebuild Scope
# 1. Clean build from Terminal at project root
xcodebuild -scheme -configuration Debug clean build
# 2. Change a public Swift API in one module, then rebuild
xcodebuild -scheme -configuration Debug build
# 3. Inspect DerivedData/Build/Intermediates.noindex for timestamps.
# Only the changed module and its direct dependents should show new compile timestamps.
Risk: changing a private implementation detail should not trigger downstream recompiles. If it does, the dependency graph or module interface cache is stale.
4. Gate CI on Build Timing Summary
# Xcode 14+. Run in CI after a clean build.
xcodebuild -scheme -configuration Debug -showBuildTimingSummary
# Review phase durations and parallelism. Set thresholds, for example:
# incremental build after a single-file change under 30 seconds.
Failure Modes and Mitigations
| Failure Mode | Symptom | Mitigation |
|---|---|---|
| Stale module cache after manual file moves | "Module not found" or outdated interface errors | Use Clean Build Folder (⇧⌘K), not just Clean. Automate as a CI pre-step. |
| Run Script phase without input/output lists | Script executes every build, destroying incrementality | Declare Input Files and Output Files, or enable Based on dependency analysis. |
| Swift driver crash from divergent .swiftinterface across architectures | Internal compiler error during module merge | Use one Swift toolchain for all architectures; avoid mixing Xcode versions on the same DerivedData. |
| "Too many open files" during parallel linking | EMFILE kernel errors in large projects | Raise ulimit -n 4096 in CI, or lower Maximum Concurrent Compile Tasks in Build Settings. |
| Code signing failure late in the graph | Compile and link succeed; Sign phase fails | Validate provisioning profiles early with xcodebuild -showBuildSettings | grep PROVISIONING_PROFILE. |
Conditions That Would Change the Design
- Adopting Bazel or Buck for a cross-language monorepo moves graph ownership outside Xcode.
- Swift explicit module builds shift module ownership to the compiler, reducing the build system to a scheduler.
- Apple deprecating the current build graph format; currently unlikely as the .xcactivitylog format is stable.
Verification Steps
- xcodebuild -showBuildSettings -target returns NewBuildSystem for BUILD_SYSTEM.
- A clean build log shows concurrent CompileSwift tasks, confirming parallel execution.
- A single public API change recompiles only the owning module and direct dependents (check DerivedData timestamps).
- CI timing summary shows phase durations within the agreed threshold.
Limitations
- Legacy Build System was removed in Xcode 15; unmigrated projects cannot build.
- SwiftPM version-resolution conflicts are not visible in Xcode's UI; run swift package show-dependencies in the package directory.
- Module-interface caching assumes a stable compiler version; toolchain changes invalidate caches.
- Large projects may still hit file-descriptor limits on default macOS CI runners.