Xcode 13.1 bug editing dependency as local

Viewed 410

Just upgraded to Xcode 13.1 and opened a SPM project by clicking the Package.swift file that has some dependencies. In the former versions I could simply edit one of these dependencies by dragging a local clone of the package into the Project Navigator. Xcode was then going to ignore the checked out dependency and let me edit the local one. Apple documents this here.

When trying this with Xcode 13.1, Xcode just copies the folder into the project folder, like it does with normal files/folders that are not SPM projects.

Did I find a bug or missed I something?

Thanks!

Update: I found out how to work around by creating a .xcodeproj file with swift package generate-xcodeproj. There I could drag in the package as always. This works but is not the way to go, as the xcodeproj generation is deprecated by apple.

2 Answers

It looks like there is now an Add Local... button at the bottom of the add package wizard. Selecting the package from your local filesystem yields the same result as the "drag from finder" instructions you've linked.

The wizard is accessible from:

  • File > Add Packages, or
  • Project.xcodeproj > Package Dependencies > +.

I was having this problem, too, but after seeing the first comment on the other answer, I tried this:

I used File->Add Packages->Add Local…->navigate to local clone of dependency->Copy Package, which indeed seems to do nothing, but it puts a .package dependency line onto the clipboard.

I then edited my main project’s Package.swift to replace the existing Github dependency with the contents of the clipboard. Now I can edit the dependency’s files directly in the “Package Dependencies” portion of the project contents pane (which I wish you could do for a regular Xcode project too).

This solution kinda sucks, because it forces me to modify Package.swift, which means everyone on the team has to set things up the same way. Fortunately, I'm the only one working on this project, but future me is sure to be bitten by this.

Related