Swift packages: Sharing code between libraries (while exposing some APIs from the shared code)

This is deliberately prohibited because it can break everything for a C target. For Swift it could theoretically be made legal, but portions of the binary can end up needlessly duplicated, so it is still generally a bad idea. If absolutely necessary, I think you can trick SwiftPM using symlinks.

These are covered by the incomplete experimental features @_spi and @_exported (which are nonetheless mostly functional). You can learn about them by searching for them in the source code and on the forums, and I am sure any help towards completing them would be welcome.

1 Like