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

The entire UX with fetching SPM repositories is confusing. I cannot believe no one at Apple ever noticed it. I've tons of "missing package product" error until it finish the fetch (and sometimes it fails with no detailed log so i need to clean all derived data and .swiftpm folders and try again). Unfortunately it still not works on Xcode 13 and it's a pain.

1 Like

I also constantly got "Missing package product" error in Xcode 13 after switching git branches. Clearing DerivedData and .swiftpm folders didn't work for me. Have no idea why, but issue was resolved after building project from Terminal. Just run xcodebuild -workspace "MyProjectWorkspace" -scheme "Target", and after successful build, you can use Xcode without such errors.

2 Likes

I'm also seeing this constantly with Xcode 13 (and 13.1). Trashing DerivedData, opening an Xcode project, seeing Resolve Packages succeed, and then upon starting a build seeing "Missing Package Product" for multiple SPM targets.

Restarting Xcode is the only way to fix this, and it builds correctly without issue after that point.

@maksym_kulyk's suggestion also magically fixes things ¯\_(ツ)_/¯

Switching branches also seems to trigger this :(

We see the same thing with both local packages and and remote packages that have binary targets on Xcode 13.0 . Closing Xcode, running xcodebuild -resolvePackageDependencies seems to fix the issues and then Xcode works after that.

4 Likes

I can confirm we're also seeing this with Xcode 13. I thought the whole delete derived data dance we used to have to do was a thing of the past, now it's far worse, we have to clear derived data, reset package caches, restart Xcode etc, so frustrating. I'm so close to giving up with SPM and Xcode's integration as I've wasted so so much time investigating issues like these. Might give Tuist a go.

I just ran into this issue as well. Took me a while to get everything building again, as restarting xcode/cleaning DerivedData or resolving swift packages did not help. What finally helped for me was to remove swift pm caches by using rm -rf ~/Library/Caches/org.swift.swiftpm/.

I constantly run into this issue as well using Xcode Version 13.2 beta (13C5066c) with the following setup:

.
├── package
│   ├── Package.swift
│   ├── Sources
│   ├── Tests
│   └── ...
├── app-A
│   ├── app-A
│   ├── app-A.xcodeproj
│   └── ...
└── app-B
    ├── app-B
    ├── app-B.xcodeproj
    └── ...

Both apps A and B reference the local swift package. I can work on App A without issues. Then I'm continuing work on App B and get the 'Missing package product ...' error in Xcode. I can resolve this error using the workarounds/commands mentioned above until App B finally builds again in Xcode. Now when I switch back to work on App A I'll get the same issue there. Fixing it will again mess things with App B etc...

Some ways to fix the issue (some of them mentioned above)

  • Regenerate your workspace fixes the problem in 80% of cases (.xcworkspace contains Package.swift file, so spm has to recompute package graph)
  • Sometimes you may have to reset package caches rm -rf ~/Library/Caches/org.swift.swiftpm
  • xcodebuild -workspace "<workspace>.xcworkspace" -scheme "<scheme>" may fix it too
  • I'd also give clearing DerivedData a chance

But I almost get rid of this issue by migrating packages from ssh to https and adding the nested dependency, that caused the issue to some top-level package
My project has a pretty complex structure, but the simplified version looks kinda like that

- RootPackage
  - Dependency1
    - NestedDependecy
  - Dependency2
    - SomeOtherDependecy
      - NestedDependecy

New structure looks like that

- RootPackage
  - NestedDependecy
  - Dependency1
    - NestedDependecy
  - Dependency2
    - SomeOtherDependecy
      - NestedDependecy

Also, I'd recommend to add package product, that missing to some top-level target as a dependency too.

Am I understanding this correctly that you're trying to open both projects at the same time?

Thank you for following up. I tried various combinations of opening/closing project A/B now and you're right that in my case the issue only appears if both projects are (or previously were) open at the same time.

Open project A > Build succeeded
Open project B (w/o closing A) > Building B failed with Missing package product
Close project A > Building B still fails with Missing package product
Close project B (w/o quitting Xcode) & open project B again > Build succeeded
Close project B & open project A > Build succeeded

I guess my issue was that I should close one project before opening the other.

This has been our experience with Xcode the last couple weeks as well, and it seems to be mostly the GUI. xcodebuild in terminal usually works. We are having to constantly close Xcode, delete derivedData, reset caches and/or run xcodebuild -resolvePackageDependencies because of this missing package products error (all the missing package products are local packages in the same repo as our main iOS project).

Here we go again. I've just updated Xcode to 13.2 and can't build the project. It just can't fetch packages. All worked on 13.1.
cc @NeoNacho

Yep, SPM seems to be completely broken with 13.2, CLI swift build works tho...

2 Likes

Same issue with a clean App Store install of Xcode 13.2 in two projects, and I never had this issue before. In addition, adding a package results in an infinite hang on "Preparing to validate...".

1 Like

I'm seeing the same issue (FB9807887):

Internal error: missingPackageDescriptionModule
1 Like

Same here - also reported in FB: FB9807816. I've now wiped my machine and reinstalled from MAS as well as direct downloads.

the RC2 (identical reported build of Xcode) direct download isn't having any issues, but the MAS installed version does. I reinstalled Xcode 13.1 (from XcodeReleases.com) and it's also fine.

The MAS version will also fail to build a brand new swift package from the default template installed with it (e.g. Xcode -> New Swift Project -> ... take all the defaults). Same error message there.

2 Likes

https://developer.apple.com/forums/thread/696504?answerId=698142022#698142022

5 Likes

Seeing the same issue after Xcode 13.2 update via Mac App Store. Initially I was getting "Internal error: missingPackageDescriptionModule". Then I removed the package setting from my project settings and selected the same package to start over. But now I get the hang on preparing to validate. Removed only the derived data folder, reset packages caches, rebooted, looked over privacy settings, reset Xcode select path, updated projects to new Xcode version, checked command line tools is 13.2 (13C90). Let Xcode sit hoping for a time out but nothing happened.

I just have one dependency which is Swift Atomics listed under Apple Swift Packages. Never seen this problem prior to the 13.2 final update. M1 Mac. I did see in the macOS 12.1 update a note it was going to update my command line tools too. Just feedback on hot potato.

I'm seeing this too.

It's shocking that this is still on the AppStore. Even the release notes admit that it's broken.

I know this forum isn't supposed to be about Apple or their distribution policies, but -- this is the official Swift toolchain, shipped as part of Swift's premier IDE. I think it is reasonable to be a little bit annoyed and feel a little bit like your time is not being valued when your entire workflow is broken by a widely reproducible bug :triumph:

Not to mention that this follows the launch of Swift Concurrency, which itself miscompiled even the most basic of tasks (like passing an enum to an actor).

It's just not good enough. It just isn't.

6 Likes