How does the module system actually work in Swift? From what I've seen so far it seems to be pretty tied in with XCode and tools like the package manager.
Can you clarify your question a little bit? What specific information are you looking for?
Here are some random notes which may help clarify things:
1. There are two kinds of modules, C-family modules (which come from Clang's module system, which is layered on top of C headers) and native Swift modules (.swiftmodule files).
a. For Clang modules, see http://clang.llvm.org/docs/Modules.html for information on these. Those modules are found via the Clang importer built into Swift. swiftc has command line options to expose search paths to the Clang compiler which in turn control how those modules are found -- those options aren't currently exposed by the package manager directly.
b. Swift modules are found using a much simpler search path mechanism, which can also be controlled via swiftc command line options. Again, the package manager doesn't expose those options directly.
2. The package manager currently assumes each "target" will be its own Swift module. It automatically adds search path options so that dependents can see their dependencies, whether in the same package or across packages.
3. If you run `swift build -v` you can see what options are going to swiftc to make this work. The interesting ones are -I (which controls search paths, as with Clang), and -emit-module*.
On Dec 4, 2015, at 8:54 PM, Severen Redwood <email@example.com> wrote:
I come from languages like Rust where modules either map to files or to folders with a `mod.rs <http://mod.rs/>` file inside. I can also define modules inside of source files with the `mod` keyword.
From what I've seen the way modules work in Swift is not very flexible.
swift-users mailing list