Using multiple SPM packages with shared local package dependency not supported (in Xcode)?

I'm trying to set up the structure for a set of SPM packages that I'd also like to open / build in Xcode (13.1).

It seems I've run into some fundamental issue here, just want to see if anyone else has encountered this or have any workaround.

Basically, I have library packages A, B and C (and then there are executable D and E that will depend on A/B).
A depends on C
B depends on C

I've set up the dependency for a local package as such in both A and B:

    dependencies: [
        .package(path: "../C")

From a clean startup of Xcode, I can work with A or B and get the package C properly resolved with a fold-down arrow so I can edit the local copy as well as building A or B properly.

But if opening both A and B in Xcode, the secondly opened copy will not get a fold down and can't build as it fails with:

Missing package product 'C'

I've tried cleaning SPM package caches and build folders, but no go. If I open B first instead, A will fail, so it seems clearly related to which order these are opened.

I want to be able to open both A and B in Xcode and work in parallel on them, preferably with the fold down of the local package C such that it can be edited regardless of where my focus is at the time.

I also opened FB9796870 with a reproducer, but hoped there was some way to get this to work.

Command line builds with SPM works fine for both, I guess that is always a workaround, but would have been nice to be able to work from Xcode too.

It seems to be a known limitation from SPM day 1 for me.

I guess maybe there are some conflict issue so that Xcode team disabled this feature?

For SPM it seems to work on the surface at least - but haven’t tried the resulting compiled units yet as I’m just setting up the project structure at the moment.

You cannot have a local package open in more than one Xcode workspace/project at a time.

1 Like

Ouch. Thanks - quite unexpected (the UI feedback made it seem like a defect) - seems like a reasonably desirable workflow for just slightly more complex projects, but then I know...

That's what workspaces are for. You can add multiple projects/packages to the same workspace. Then, you can view A, B, and C at the same time.

1 Like

Many thanks, I'll check it out (but I did like being able to ad-hoc open packages in Xcode and not have any persisted Xcode assets if possible... Especially nice when you start having a more complex project with dozens or hundreds of libraries / services which are edited in different environments.).

Terms of Service

Privacy Policy

Cookie Policy