Skip to content
Latchkey

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.

xcodebuild output
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.

Terminal
xcodebuild -resolvePackageDependencies -workspace App.xcworkspace -scheme App
# or update pins when a constraint changed:
swift package update

Cache SPM and provide credentials for private packages

Cache the resolved packages and ensure private Git URLs can authenticate.

.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/Library/Developer/Xcode/DerivedData/**/SourcePackages
    key: spm-${{ hashFiles('**/Package.resolved') }}

Resolve a version conflict

  1. Read which two requirements conflict in the error.
  2. Loosen your own version range so it overlaps the dependency’s.
  3. Upgrade the lagging package to a release that accepts the newer shared dependency.

How to prevent it

  • Commit Package.resolved so 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →