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

**URL:** <https://forums.swift.org/t/xcode-fails-to-resolve-locked-package-resolved-file-when-switching-git-branches-while-xcode-app-is-open/40991>\
**Category:** Using Swift\
**Tags:** packagemanager\
**Created:** [October 7, 2020, 11:22pm UTC](https://forums.swift.org/t/xcode-fails-to-resolve-locked-package-resolved-file-when-switching-git-branches-while-xcode-app-is-open/40991 "2020-10-07T23:22:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ray](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@ray](https://forums.swift.org/u/ray)\
**Post date:** [October 7, 2020, 11:22pm UTC](https://forums.swift.org/t/xcode-fails-to-resolve-locked-package-resolved-file-when-switching-git-branches-while-xcode-app-is-open/40991/1 "2020-10-07T23:22:57Z")

</div>

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](https://github.com/raymondk-nf/LocalSwiftPackageTest)  
Follow Swift forum thread here: ["Missing package product" error for all local Swift Packages when switching git branches - #3 by ray](https://forums.swift.org/t/missing-package-product-error-for-all-local-swift-packages-when-switching-git-branches/38041/3)

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.

---

<div class="post-metadata">

**Author:** ![ray](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@ray](https://forums.swift.org/u/ray)\
**Post date:** [October 7, 2020, 11:23pm UTC](https://forums.swift.org/t/xcode-fails-to-resolve-locked-package-resolved-file-when-switching-git-branches-while-xcode-app-is-open/40991/2 "2020-10-07T23:23:41Z")

</div>

@NeoNacho Filed a Radar FB8783743

---

<div class="post-metadata">

**Author:** ![Nampoton](https://avatars.discourse-cdn.com/v4/letter/n/57b2e6/32.png) [@Nampoton](https://forums.swift.org/u/Nampoton)\
**Post date:** [May 25, 2021, 3:15pm UTC](https://forums.swift.org/t/xcode-fails-to-resolve-locked-package-resolved-file-when-switching-git-branches-while-xcode-app-is-open/40991/3 "2021-05-25T15:15:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [May 25, 2021, 9:31pm UTC](https://forums.swift.org/t/xcode-fails-to-resolve-locked-package-resolved-file-when-switching-git-branches-while-xcode-app-is-open/40991/4 "2021-05-25T21:31:05Z")

</div>

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

> [@Package.resolved being reset after checking out a branch with updates](https://forums.swift.org/t/package-resolved-being-reset-after-checking-out-a-branch-with-updates/48634):
>
> I’ve got a swift package and I’m running into an issue when switching branches from main to a branch that has updated a dependency. When I swift build it causes the Package.resolved to be changed back to the version from main . I expect it’s getting the versions based on the checked out dependencies in .build since running swift package reset before swift build will make it use the versions in Package.resolved . I’ve only been able to reproduce it using [Apollo](https://github.com/apollographql/apollo-ios.git) but nothing looks weird about their…
