`swiftcrossimport` dependency declaration

Hi all,

I'm in the process of experimenting with crossimportmodule as a potential path forward for our modular project.

To the extent that I've looked at the proposal and experimented, I've come this far along:

  1. I have declared a swiftcrossimport that is being properly placed in the same directory as the modulemap in the build .framework.
  2. I have declared a new framework, _ModuleA_ModuleB that correctly @_exports import ModuleA and import ModuleB.
  3. In files that have both import ModuleA and import ModuleB, the cross-import dynamic lookup table is being correctly consulted, and import ModuleA is being replaced as expected with import _ModuleA_ModuleB.

However, if I have not already manually built _ModuleA_ModuleB, there will be nothing that will trigger the build of that module as it's not declared as an explicit dependency of the current module/project. Is this intended? If so, I assume I am meant to declare in my dependency structure an explicit dependency on _ModuleA_ModuleB -- and assuming "yes", how is that better/different from just declaring a standard module? If not, then how can I inform the compiler to build this module?

(Edit: for the sake of clarity, I'm using an xcodeproj, generating my project using xcodegen, and manually declaring dependency structure for frameworks and app targets via xcodegen not SPM)

I imagine this is the expected behavior today, since cross-module overlays aren't a fully supported feature yet. They work for system frameworks by virtue of the fact that they're already compiled in the SDK so the build system doesn't have to do any dependency tracking, but tooling like Xcode and SPM would need to also be updated to be aware of them for user code.

That makes sense and seems to track with my expectations insofar as I've experimented.

Are you aware of an issue or proposal tracking the addition of these systems into SPM or publicly available Swift tooling? The proposal that I largely based my work on made note that future work is required in SPM and other tools, but I couldn't seem to locate such a proposal for SPM.

AFAIK, beyond the pitch you linked, there haven't been any proposals to formalize the feature in the compiler or add support in SPM.

1 Like