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

I'm seeing a consistent Xcode error for all of my local swift packages when switching git branches or doing a git pull while Xcode is open.

A workaround that works ~75% of the time:

  1. Kill xcode
  2. Then completely remove the derived data directory (empty trash just to be absolutely sure).
  3. Restart Xcode
  4. Reset Swift package cache

On some occasions, this workaround fails and am forced to do a fresh git clone. Has anyone else seen this before?
Xcode Version 11.5 (11E608c)
swift-tools-version:5.2

2 Likes

What are the errors in your package resolution log? You can find that in the report navigator under the project/workspace node.

@NeoNacho The Package resolution log shows no errors. Looks like it only applies to remote swift packages. Here is the export of the log. The error above is specifically for local packages only.
Package Resolution log:

Showing All Messages   
Resolve Package Graph
Activity Log Complete    6/30/20, 11:26 AM    7.5 seconds

Build log:

Showing All Messages

Prepare build
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description

Build target <target name> of project <project name> with configuration Debug
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
error: Missing package product '<local package name>' (in target '<target name>' from project '<project name>')
Build failed    6/30/20, 11:19 AM    1.2 seconds

I'm slightly confused by these logs, for two reasons:

  • According to the time stamps, the resolution log is newer than the build log, but resolution has to happen before the build. Could you check if there are any errors in previous logs?

  • It looks like this is a different case than the initially reported one, this log is missing the extra "Package resolution errors must be fixed before building" the previous one had. This could potentially be an issue with the log export that I am not aware of though.

@NeoNacho I created a sample app which demonstrates this. It contains a dynamic framework linking into a app target. Two remote swift packages and one local swift package statically link into the framework.

I built master, then git checkout Test -- on command line, tried to build and failed instantly, all while Xcode is open.

This feels more like an Xcode bug rather than a Swift Package Manager issue. I filed a radar: FB7831146

1 Like

same issue here

I get this same kind of problem with Cocoapods and Xcode when switching branches. I may have different versions of specific pods in the different branches. I pod install after switching the branch but Xcode doesn't seem to notice that the dependencies have changed so doesn't build them. I get link errors for methods that are in one version of a pod but not in another so I can tell it didn't build the dependency.

This all started for me with the new build system. You might try to see if the legacy build system works better.

Usually Clean Build Folder works to fix this for me.

Our team is also experiencing this - we use both Cocoapods (for now) and SPM and our local packages do this every time we switch branches. What works for me is closing the workspace before switching branches... which is annoying to say the least. Is there anything we can do to help get this fixed?

Package resolution log:

Showing All Messages
Resolve Package Graph


Activity Log Complete    05/08/2020, 10:31    0.6 seconds

Build log:


Showing All Messages

Prepare build
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Using build description from memory



Build target <name> of project <name> with configuration Debug
error: Missing package product 'Deeplinks' (in target '<name>' from project '<name>')
error: Missing package product 'LocationProvider' (in target '<name>' from project '<name>')
error: Missing package product 'CountryCodes' (in target '<name>' from project '<name>')
error: Missing package product 'ReachabilityInternetProvider' (in target '<name>' from project '<name>')
error: Missing package product 'LanguageCodes' (in target '<name>' from project '<name>')
error: Missing package product 'BaggageDistributor' (in target '<name>' from project '<name>')
error: Missing package product 'ReachabilityInternetProvider' (in target '<name>' from project '<name>')




Build failed    05/08/2020, 10:31    0.2 seconds

This is on Xcode 11.6.

1 Like

We are aware of this and are investigating.

2 Likes

Update: Got a reply from my Apple Radar FB7831146 to retest against Xcode 12 Beta 5. Issue still exists.

Sorry, seems like there was a mistake somewhere. There is no fix for this in Beta 5 and you shouldn't have been asked to verify.

Terms of Service

Privacy Policy

Cookie Policy