<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Dec 4, 2015, at 8:54 PM, Severen Redwood &lt;<a href="mailto:severen.redwood@gmail.com" class="">severen.redwood@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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.</div></div></blockquote><div><br class=""></div>Can you clarify your question a little bit? What specific information are you looking for?</div><div><br class=""></div><div>Here are some random notes which may help clarify things:</div><div><br class=""></div><div>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).</div><div><br class=""></div><div>a. For Clang modules, see <a href="http://clang.llvm.org/docs/Modules.html" class="">http://clang.llvm.org/docs/Modules.html</a> 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.</div><div><br class=""></div><div>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.</div><div><br class=""></div><div>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.</div><div><br class=""></div><div>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*.</div><div><br class=""></div><div>HTH,</div><div>&nbsp;- Daniel</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">I come from languages like Rust where modules either map to files or to folders with a `<a href="http://mod.rs/" class="">mod.rs</a>` file inside. I can also define modules inside of source files with the `mod` keyword.</div><div class=""><br class=""></div><div class="">From what I've seen the way modules work in Swift is not very flexible.</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=AdkfTiApI80cNEyortTzHbERtY5det-2FDBvSxuhs4q2MjkeeVkawdFdk5YNWuefx2RDuNYOhPWLEsMieG4mw-2FZnE9vfLnqPdyaNBpFCtdneR44buSUaiyN7FLZ7PYZ5JXSt4VwkiBrr3sdMPBemsm9WdwFdJaDk7j5h0FVaPyFC6jNTYvikP9hzjC5rZzBFWa9SqqR3Sh2WNOEqcQOsfvDYHUNmna0qrW0E-2FN8FSYfDI-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></body></html>