30

I've local Swift Packages added to a workspace. They reside in the project subfolders and connected to different git repositories as git submodules. Everything had been working perfectly (the project was able to build, packages were able to resolve, and I could edit the packages within the same workspace).

After I updated Xcode to 13.0, the project started failing to build with multiple errors Missing package product for each local package dependency. Removing derived data, resetting packages, cleaning build folder and restarting Xcode didn't help.

lazarevzubov
  • 1,767
  • 2
  • 14
  • 24
  • I have this problem, and none of these solutions work for me. I'm using Xcode 13.2.1 – Hack Saw Jan 19 '22 at 00:55
  • 1
    @Yodagama I trust Hack Saw said that none of these solutions work for them. The solution you pointed out is one of the referred "these". – lazarevzubov Jun 28 '22 at 08:55

8 Answers8

57
  1. Quit Xcode

  2. Open Terminal

  3. Navigate to the directory where your .xcodeproj is via Terminal (cd path/to/your/apps/folder)

  4. Run xcodebuild -resolvePackageDependencies

  5. After the packages finish resolving, open Xcode and try building again.

Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
YodagamaHeshan
  • 4,996
  • 2
  • 26
  • 36
  • 2
    But in addition I had to add the framework to each target (iOS and macOS in my case), in targets' Build Phases : Link Binary with Libraries – rudifa Nov 26 '21 at 18:53
  • 2
    This is by far the leanest approach to solve this issue it worked for me on different computers with different Xcode Versions, Thanks Yodagama and @DanielStorm for the edits – Jorge Vicente Mendoza Mar 10 '22 at 10:29
  • 2
    This worked for me, even when Xcode > File > Packages > Resolve did not. – Donald Jul 07 '22 at 15:00
  • This answer **definitely works** but if running this gives anyone a command line error of `xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance` then try this https://stackoverflow.com/a/72115137/4833705 first before this answer – Lance Samaria Aug 18 '22 at 00:29
6

This is what worked for me:

  • Click on the project file then go to Project (not a target) -> Package Dependences tab.
  • Double-click on any Package and copy the location URL to clipboard.
  • Remove that Package using the - button.
  • Add it back, pasting the URL.
  • Clean Build Folder, then Build.

Alternatively, removing an unused package in the Target -> Build Phases -> Link Binary With Libraries, also removed the errors for me.

elprl
  • 1,940
  • 25
  • 36
2

Removing package references from workspace and re-adding them (by simple drag-n-drop from Finder) resolved the problem.

I even didn't need to reconfigure corresponding schemes, or re-adding dependencies in targets.

lazarevzubov
  • 1,767
  • 2
  • 14
  • 24
1

If @lazarevzubov's answer doesn't help, try few additional steps:

  • Open xcode
  • Delete one or couple of libs under Build Phases / Link Binary with Libraries
  • Discard changes under git
  • Clean project
  • Close xcode
  • Run xcodebuild -resolvePackageDependencies
  • Open xcode again and try to build
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Haseeb Iqbal
  • 1,455
  • 13
  • 20
1

In XCode,

File > Swift Packages > Reset Package Caches

Vishal
  • 1,232
  • 1
  • 6
  • 8
1

This has occasionally happened to me when I have the package I want to use as a local package open in other Xcode windows. Closing other Xcode windows that have that package project open or are also using it as a local package may help. (Close those other windows, then try re-adding it as a local package.)

Liam
  • 108
  • 5
0

In my case, the problem was an expired certificate on GitHub. I had to create a new certificate so that packages could be loaded.

Kateridzhe
  • 227
  • 3
  • 4
0

Another possible issue not mention above. Look for an empty folder in the project folder with the same name as the local package. This can confuse the linker. Also, git will not pick this since git does not see empty directories. Just delete the empty folder.

bauerMusic
  • 5,470
  • 5
  • 38
  • 53