Swift Package Manager "failed to resolve dependencies" in CI
Swift Package Manager could not compute a set of package versions that satisfies your dependencies. Either a package URL is unreachable, Package.resolved is stale, or two requirements are incompatible.
What this error means
A build or xcodebuild -resolvePackageDependencies fails with "failed to resolve dependencies" - sometimes naming a package it could not fetch, sometimes a version conflict. Network causes pass on retry; conflicts and stale pins fail every time.
error: failed to resolve dependencies:
Dependencies could not be resolved because root depends on 'swift-log' 1.5.0..<2.0.0
and 'metrics' depends on 'swift-log' 1.0.0..<1.5.0.Common causes
Stale or conflicting Package.resolved
A Package.resolved that no longer matches Package.swift, or two packages requiring non-overlapping versions of a shared dependency, leaves SPM with no solvable set.
Unreachable package URL
A transient network failure or an auth issue cloning a Git package URL (a private repo without credentials) makes resolution fail to fetch the package.
How to fix it
Re-resolve and update the pins
Refresh the resolved file so it matches the manifest, then resolve.
xcodebuild -resolvePackageDependencies -workspace App.xcworkspace -scheme App
# or update pins when a constraint changed:
swift package updateCache SPM and provide credentials for private packages
Cache the resolved packages and ensure private Git URLs can authenticate.
- uses: actions/cache@v4
with:
path: ~/Library/Developer/Xcode/DerivedData/**/SourcePackages
key: spm-${{ hashFiles('**/Package.resolved') }}Resolve a version conflict
- Read which two requirements conflict in the error.
- Loosen your own version range so it overlaps the dependency’s.
- Upgrade the lagging package to a release that accepts the newer shared dependency.
How to prevent it
- Commit
Package.resolvedso CI resolves to the same versions. - Cache the SPM SourcePackages directory keyed on
Package.resolved. - Provide credentials for any private Git package URLs in CI.