SwiftPM "could not resolve package dependencies" in CI
SwiftPM could not produce a valid dependency resolution. Either it failed to fetch a package, or no combination of versions satisfies every requirement.
What this error means
swift build or resolve fails with a dependency resolution error - a version conflict or a fetch failure. Conflicts are deterministic; fetch failures are transient.
error: Dependencies could not be resolved because root depends on
'alamofire' 5.9.0..<6.0.0 and 'foo' depends on 'alamofire' 4.x.
error: failed to clone https://github.com/org/foo.gitCommon causes
Conflicting version requirements
Two packages require incompatible version ranges of a shared dependency, so no resolution exists.
Fetch or clone failure
A package repository could not be cloned due to a network error, bad URL, or missing auth.
Stale Package.resolved
A committed resolution pins versions that no longer satisfy updated requirements.
How to fix it
Align version requirements
- Read which packages conflict over which dependency.
- Relax your own bound or upgrade the lagging package.
- Run
swift package updateto recompute a valid set.
Provide credentials and retry fetches
Supply auth for private packages; retry transient clone failures. On Latchkey managed runners, self-healing auto-retries transient package fetch failures so a one-off clone error does not fail the job.
swift package resolveRefresh a stale resolution
Delete and regenerate Package.resolved when requirements change.
rm Package.resolved && swift package resolveHow to prevent it
- Keep dependency version ranges compatible.
- Commit Package.resolved and update it deliberately.
- Cache the SwiftPM cache directory.