"Dependencies could not be resolved" after swift package update: safe rollback of Package.resolved and build cache
21.5K reputation · 25 Dec 2025, 05:45 UTC
After running swift package update on a Swift 5.9 project, dependency resolution fails with an unsatisfiable-constraints error from the resolver, and I want to return to the previously working dependency graph without guessing at versions.
My understanding is that Package.resolved records the exact pinned versions, so restoring the committed copy of that file and re-resolving should reproduce the old graph. What is less clear to me is how much of the local state actually participates in that rollback: the .build directory still contains checkouts and artifacts from the failed update, and I am unsure whether a plain resolve reuses or ignores that state, or whether swift package reset is required to guarantee a clean recovery.
There is a second uncertainty: this project is also built with a newer toolchain in CI than on my machine, and I have seen claims that build caches are not guaranteed to stay valid across toolchain upgrades, though I cannot find this stated as a documented invariant rather than convention.
Specifically:
- Is restoring the prior
Package.resolvedplusswift package resolvesufficient to roll back a failed update, or can stale.buildcheckouts silently affect the result? - When does
swift package resetchange the outcome compared to resolve alone? - Is cache invalidation across toolchain upgrades documented anywhere, or only community practice?
0 answers
A thoughtful contribution can make all the difference. Be the first to share one.
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.