Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local Swift Packages Stopped Working in Xcode 13

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.

like image 543
lazarevzubov Avatar asked Sep 22 '21 09:09

lazarevzubov


People also ask

How do I add a Swift package dependencies in Xcode 13?

To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL.

How do I add a local package to a project in Swift?

Open your Xcode project and create a local Swift package as part of your project by selecting File > New > Swift Package. Choose a project and a group, but don't create a new Git repository if your app is already under version control; then create the new Swift package.

How do I update Swift package dependencies?

To resolve, Open the project from the project panel, select the project (not the targets), then select the "Swift Packages" tab. Double click on the package you want to update and change the minimum version to the next major version.

How do I open a Swift package in Xcode?

You can double-click it in Finder to open the package in Xcode. The package manifest uses Swift and the PackageDescription framework to define the package's name, products, targets, dependencies on other packages, and so on.


2 Answers

  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.

like image 196
Yodagama Avatar answered Nov 08 '22 09:11

Yodagama


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.

like image 27
elprl Avatar answered Nov 08 '22 09:11

elprl