How to add local Swift Package as dependency?

Same here in Xcode 13. When I delete the derived data folder, open Xcode then the local package is not found....

Build failures only appear if you add the package in the scheme editor (scheme it it dependency of) to the build section. But this is strange in times of implicit dependenc resolution...

i see, during this time i had actually solved the original issue.

it seems a default behavior in swift to hide build errors not in the current scheme proper (xcode considers spm external to the selected scheme i guess)

This is the way! It's not enough to close and reopen the project. You have to close Xcode. This certainly smells like an Xcode bug.

Let's say you have a remote package dependency that you want to edit locally within the project that depends on it. Clone the package to your file system. Remove the remote package reference from your client project. Drag the folder containing the dependency Package.swift to the project explorer of your client project in Xcode. I usually drop it at root level so I see it front and center rather than in a sub folder. You'll see the package icon and name with no disclosure error allowing you to edit files. Kill Xcode completely. Reopen Xcode and your project. Ta dah! You can now edit as a local package dependency.

1 Like

You don't have to remove the remote package reference. If you add a local package to your project/workspace, Xcode will automatically use it instead of the remote version. Then, if you remove the local package, Xcode will automatically switch back to the remote version.

This is probably because you have the Package open in a separate window. You must close this window before dragging the package into another project.

seems the only working solution for local repos. Tested under Xcode Version 13.3.1 (13E500a)