Skip to content
Latchkey

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.

swift
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.git

Common 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

  1. Read which packages conflict over which dependency.
  2. Relax your own bound or upgrade the lagging package.
  3. Run swift package update to 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.

CI step
swift package resolve

Refresh a stale resolution

Delete and regenerate Package.resolved when requirements change.

CI step
rm Package.resolved && swift package resolve

How to prevent it

  • Keep dependency version ranges compatible.
  • Commit Package.resolved and update it deliberately.
  • Cache the SwiftPM cache directory.

Related guides

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