Xcode fails to resolve locked Package.resolved file when switching git branches while Xcode app is open

Xcode and Swift Package Manager fails to resolve locked Package.resolved modules when switching between git branches while Xcode app is open.

Tested on Xcode 12.0.1 and 12.2 beta 2 (12B5025f)
Occurs about 75% of the time.

Sample app can be found here: GitHub - raymondk-nf/LocalSwiftPackageTest
Follow Swift forum thread here: "Missing package product" error for all local Swift Packages when switching git branches - #3 by ray

Repro steps:

  1. Open Test projected in either Xcode 12.0.1 and 12.2 beta 2 or higher
  2. Wait for Xcode to download and resolved all SPM packages.
  3. Then switch to another branch with “git checkout Test --“ while leaving Xcode app open.
  4. Observe more often than not, Xcode has altered the “Package.resolved” file unexpectedly.
  5. If not, go back to master branch and repeat steps 2-4

On master branch, SPM Apollo module is set to version "0.34.1” in Package.resolved. On Test branch, SPM Apollo module is set to version "0.28.0" in Package.resolved. After switching to Test branch, I expect Xcode to resolve Apollo module version to “0.28.0” but instead it seems as if Xcode did not recognize that Package.resolved file changed during branch switching.

1 Like

@NeoNacho Filed a Radar FB8783743

Hello,
I'm experience the same problem with Xcode 12.4. When I do git checkout on different branches, then I receive the errors as decribed above. Via "Resolve package versions" I can fix this error but I have to do it every time I switch branches and/or I do git stash pop.

Is there any progress on this issue?

This other thread has more detailed information (but still no solution):

1 Like