Swift modules, submodules and umbrella modules

Hello,

I want to create a module dependency (let’s call it Module).
I currently have created multiple modules (let’s say SubModule1, SubModule2 and SubModule3). The final module I want is a simple merge of those three submodules.

Clients can simply import the three submodules separately in their code to use the full module, however, for the sake of simplicity, I’d love to be able to merge these submodules into one, so the clients can simply import Module alone.

Is this possible?

I have tried creating Module that compiles a single file which simply typealias all of the types of the different modules. It seems to work, but is not very practical!

You can use @_exported import from a module to expose anything under the umbrella import.

1 Like

…but note that as an underscored attribute it is not officially supported.

Right. This is really nice functionality, so is there a chance of a supported version of this?

Heh. It’s come up in Evolution discussions before. I really want to redesign module imports and exports, though (in as backwards-compatible a way as possible, of course). We are not consistent with C’s behavior, which leads to some frameworks being re-exported and some not on Apple platforms, and completely different behavior on Linux.

I’ll try to grab some time to write this up more fully in Evolution/Discussion.

8 Likes