Fix: Missing Package Product Error in Xcode Swift Package Manager

Fix: Missing Package Product Error in Xcode Swift Package Manager

Written by

in

Quick answer: The ‘Missing package product’ error occurs when Xcode’s Swift Package Manager cache becomes stale after switching Git branches with local packages. Fix it by choosing File > Swift Packages > Reset Package Caches, or File > Swift Packages > Update to Latest Package Versions.

Why this happens

Xcode caches resolved package dependencies to speed up builds. When you switch Git branches that reference different versions of a local Swift package (or the same package at a different commit), Xcode’s cached package graph still points to the old package product identifiers. The cache doesn’t automatically invalidate because the Package.resolved file may not change in a way Xcode detects, especially when the local package path stays the same but its contents differ.

External packages from remote registries rarely trigger this because their versions are pinned in Package.resolved and Xcode fetches them fresh. Local packages, however, are resolved by filesystem path, so Xcode assumes nothing changed unless the path or manifest version changes.

This is a known Xcode behavior (observed since Xcode 11.4) rather than a project configuration error.

How to fix it

1. Reset Package Caches (most reliable)

This clears Xcode’s internal SPM cache and forces a fresh resolution on the next build.

  1. Open your project in Xcode.
  2. From the menu bar, choose File > Swift Packages > Reset Package Caches.
  3. Wait for the operation to finish (no visible progress indicator in newer Xcode versions).
  4. Build the project (⌘B). The missing product should now resolve.

This is the accepted solution from the community and works in the majority of cases.

2. Update to Latest Package Versions

If resetting caches doesn’t help, force Xcode to re-resolve all package dependencies.

  1. Choose File > Swift Packages > Update to Latest Package Versions.
  2. Xcode will fetch/update remote packages and re-scan local package manifests.
  3. Build again.

This also rewrites Package.resolved with the current state, which can clear the stale reference.

3. Manual cache cleanup (fallback)

If the menu items are unavailable or ineffective, delete the derived data and SPM cache directories manually:

# Close Xcode first
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/org.swift.swiftpm

Then reopen Xcode and build.

How to prevent it

  • Commit Package.resolved to version control so all collaborators use the same resolved versions.
  • Avoid switching branches with uncommitted local package changes; commit or stash first.
  • Use explicit version requirements in Package.swift (e.g., .upToNextMajor(from: "1.2.0")) rather than branch-based dependencies for local packages.
  • Run xcodebuild -resolvePackageDependencies in CI scripts to ensure a clean resolution before building.

FAQ

Does this affect only local packages?

Primarily yes. Remote packages are identified by URL and version in Package.resolved, so Xcode detects changes reliably. Local packages are identified by filesystem path, which doesn’t change when you switch branches.

Will resetting caches delete my downloaded packages?

No. It only clears Xcode’s internal resolution cache. Remote packages are re-downloaded if needed; local packages are re-scanned from their paths.

Is there a command-line equivalent for CI?

Yes. Run xcodebuild -resolvePackageDependencies before building, or delete ~/Library/Caches/org.swift.swiftpm in your CI pipeline’s prepare step.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.