Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode: Using packages in Xcode 14

I have several Swift packages in my project.

Works fine with Xcode 13.4.1.

Using Xcode 14 beta 1, all packages fail to build because of an error referencing to one of my packages:

Showing All Messages
Cannot clone from local directory /Users/...
Please git init or use "path:" for Location(scratchDirectory...

I tried:

  • in Xcode: removing the reference to the package and adding it again
  • in Xcode: removing the reference, moving the directory to a different place, create a fresh package in Xcode, move the old files into the new package directory
  • The usual Clean Build Folder and Reset Package Caches
  • creating the imported package under a new name and import the new one

The packages are part of the project (when creating: ... add to project and directory in the project)

like image 560
Gerd Castan Avatar asked Oct 26 '25 09:10

Gerd Castan


1 Answers

There is a change in the syntax for local packages, the .package(url: … syntax that used to work for packages within the project does not work anymore.

With Xcode 14 local packages that do no have their own repo MUST be referred as:

dependencies: [
    .package(path: "../MyLibrary"),
]

Now this works just fine in Xcode 14 beta, but if you're going back to the Xcode release version, you'll get numerous errors. To fix those, reset the package caches by calling

File > Packages > Reset Package Caches

I had the same issue in a project with 14 internal packages, some of them dependent on each other, and it runs fine now in both Xcode 13.4 and Xcode 14 beta.

Hope it helps

like image 158
DatBlaueHus Avatar answered Oct 28 '25 22:10

DatBlaueHus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!