xcodebuild "Could not resolve package dependencies" in CI
When you build an Xcode project or workspace, Xcode runs its own SPM resolution. This error means that resolution failed: an unreachable or private package, a stale pin, or a Package.resolved that no longer matches.
What this error means
xcodebuild fails with "error: Could not resolve package dependencies" (or "Package.resolved ... unable to resolve"), often after a scheme or dependency change.
xcodebuild: error: Could not resolve package dependencies:
failed to resolve dependencies for 'MyApp': the package 'Networking' at 'git@github.com:acme/networking.git' could not be clonedCommon causes
A private package without runner credentials
Xcode's resolver cannot clone a private SPM dependency because no SSH key or token is available on the runner.
A stale or missing resolved pin
The workspace Package.resolved points at a revision that changed or was removed, so integrated resolution cannot honor it.
How to fix it
Resolve packages explicitly with credentials
- Provide SSH/token auth for private packages before building.
- Run
xcodebuild -resolvePackageDependenciesas its own step to surface failures early. - Then build the scheme.
xcodebuild -resolvePackageDependencies \
-scheme MyApp -clonedSourcePackagesDirPath SourcePackagesRefresh the resolved pins
If a pinned revision changed, update and commit Package.resolved, then rebuild.
xcodebuild -resolvePackageDependencies -scheme MyApp
git add MyApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolvedHow to prevent it
- Run
-resolvePackageDependenciesas a distinct CI step before the build. - Commit the workspace
Package.resolvedfor reproducible resolution. - Configure private package auth before Xcode resolves.