Swift Package Manager cache invalidation after Package.swift dependency version change
0 reputation · 10 Jan 2025, 08:18 UTC
Swift Package Manager caches resolved dependencies and built artifacts locally to speed up repeated builds. The documented behavior for when those caches are invalidated after a manual edit to Package.swift is not fully specified.
The goal is to clarify the configuration transition that determines whether derived artifacts are reused or rebuilt after a dependency version change in Package.swift. Resolution is recorded in Package.resolved, while build artifacts live in derived data and packages are stored in the package cache. Documentation describes swift package clean for build artifacts but does not define its relationship to the package cache, and the specification does not define a deterministic invalidation trigger for Package.swift edits.
Behavior is assumed for Swift 5.9+ SPM and may vary with toolchain version and Xcode integration. Package cache location and invalidation rules are implementation details.
What is the documented boundary between a Package.resolved update and build cache invalidation? Under which configuration change does SPM guarantee fresh artifacts versus reuse of cached packages? Is the package cache consulted independently of derived data after a Package.swift edit?