"Missing package product" error for all local Swift Packages when switching git branches

Isn't Apple going to fix it? It's been four days.

@vine There's an updated Xcode 13.2.1 that's just been posted. The release notes showing it's explicitly aimed at two fixes - the package resolution issue from above, and another related to libConcurrency and bitcode.

3 Likes

One thing to try (it worked for me to resolve a very similar problem ["import" failing to be satisfied that the package was in scope] - Xcode 13.3.1 & macOS 12.3.1) is to not use the "Add Local .." button in the "Add Packages .." panel, but to type in a "file://.." URL (like you would "https://github.." for a web based package).

The result is quite different in that the Package is added to the "Package Dependencies" where Xcode sees it, whereas "Add Local .." puts the Package above the "Package Dependencies" where Xcode seems to ignore it. This after six hours of deleting derivatives and caches, removing and re-adding the package and cleaning the project so many times that it shines!

The above resolved the exact same problem on three different Macs - new and old.

So my package list is now:

https://github.com/me/PackOne.git   
https://github.com/me/PackTwo.git
file:///Users/me/Development/PackThree

.. and I've kissed a whole day goodbye, which I will consider worth it if this help someone else.

I might also have read:

I'm running into this issue with XCode 13.4. Specifically it's my system library packages which are not loading.

My team and I still constantly run into this issue. Using Xcode 13.4. Sometimes it happens with all packages, sometimes with just some. We have a bunch of local swift packages that we use and link to our main target. Sometimes we have to delete derived data, clean builds reset packages caches, and quit Xcode, but it often fails. Sometimes I can add a space in a package.swift and save the file which sometimes triggers Xcode to reevaluate, but its a very flakey fix.

Whenever this happens to me, I just remove one of my packages and put it back. Then things will get rebuilt, which, of course, can take a little while.

This is still a problem with Xcode 15.4 (15F31d) with remote packages.

2 Likes

I confirm. This has been for years and still is a problem for us. Once an Xcode project is complex enough with a few SPM dependencies, this error is very easy to run into. This is a daily struggle for my entire development team.

I really hope we can get this escalated to finally have a seamlessly working Xcode / SPM integration.

Yep. Running into this constantly, - at least 3 days of dev effort in our team lost just to this kind of stuff.

Wouldn't go back to Carthage or Cocoapods, but stuff like this is table stakes, and if it isn't working in a real-world project then it needs to be fixed, simple as that. The random ways that it breaks and completely blocks you when you touch anything package-related are just not acceptable if SPM and Swift are to have a life.

2 Likes

Can confirm this is still happening on Xcode 15.4 (15F31d) and a simple project with just 5 dependencies.

Very frustrating.

U can discard changes in .resolved file, or reset package caches (File -> Packages -> Reset Package Caches)

1 Like

Still happening in 2024. To solve I used clean build followed by reset package caches (File -> Packages -> Reset Package Caches).