Xcode and Swift Package Manager dependency resolution and DerivedData invalidation
0 reputation · 18 Sept 2025, 06:15 UTC
Integration between Xcode and Swift Package Manager governs how dependencies are resolved and reused across builds. Xcode uses Package.swift manifests and the persisted Package.resolved file to reproduce builds, with compiled artifacts cached in DerivedData until the manifest or resolved file changes.
The goal is reproducible dependency resolution for low-frequency releases without unnecessary rebuilds. The relevant constraints are version-sensitive behavior of Xcode and Swift Package Manager, differences in caching between local Xcode builds and Xcode Cloud, and the trade-off between committing Package.resolved for reproducibility versus allowing flexible re-resolution for ease of updates.
There is uncertainty about when Xcode triggers re-resolution and how DerivedData invalidation is applied at the Xcode-SPM boundary.
Under what conditions does Xcode re-resolve packages versus reuse an existing Package.resolved? Does a change to Package.swift always result in DerivedData invalidation for the affected packages? What practice best balances reproducibility and update flexibility for teams with infrequent releases?