SwiftPM: Depending on a product from the same package

I asked that same question a year ago and got no answer, so I’m glad to hear this matters to someone else:

I have been tracking the development of SwiftPM and since then and I have not noticed any improvements in this area.

As you note, splitting B into a separate package is the only way to make it work.

If there are upstream dependencies used by both, you can have only the bottom library depend on them, but use @_exported import to pass access to them onward to the top library. It’s not perfect though, because if B has another dependency C that also shares the upstream dependency, but is neither used by A nor depends on A, then C’s isolation from A will cause it to still duplicate the upstream symbols in order to get access to them, leading to B getting the symbols both from A and from C.

1 Like