What are Explicit modules?
Asked on 07/30/2024
1 search
Explicit modules are a new way of building Swift and Clang modules in Xcode, introduced to improve the build process. Here are the key points about explicitly built modules:
-
Phases of Compilation: Xcode splits the compilation of each source file into three separate phases: scanning, building modules, and finally building the original code. This is different from the previous approach where these operations were performed implicitly as part of compiling source files.
-
Build System Control: Explicitly built modules put the build system in control of module builds. This means that the build system is now aware of the module graph and can make more informed scheduling choices, leading to more efficient builds.
-
Build Logs and Timeline: The build logs now show explicit scan tasks, module compile tasks, and the original source file tasks. This detailed breakdown helps in better parallelism and clearer error messages if the build fails due to a module issue. The build timeline also reflects these explicit modules, making it easier to see where time is being spent during the build process.
-
Efficiency and Reliability: Builds are more reliable with precise dependencies and deterministic build graphs. The compiler runs the same way every time, and any build failures can be reproduced by running the failing task again in isolation. This also means that a clean build now rebuilds modules, leading to more predictable and reliable builds.
-
Debugging Improvements: Explicit modules make debugging faster since the debugger (LLDB) can reuse the build outputs when evaluating expressions.
For more detailed information, you can refer to the session Demystify explicitly built modules.
Relevant Sessions

What’s new in Xcode 16
Discover the latest productivity and performance improvements in Xcode 16. Learn about enhancements to code completion, diagnostics, and Xcode Previews. Find out more about updates in builds and explore improvements in debugging and Instruments.

What’s new in Swift
Join us for an update on Swift. We’ll briefly go through a history of Swift over the past decade, and show you how the community has grown through workgroups, expanded the package ecosystem, and increased platform support. We’ll introduce you to a new language mode that achieves data-race safety by default, and a language subset that lets you run Swift on highly constrained systems. We’ll also explore some language updates including noncopyable types, typed throws, and improved C++ interoperability.

Demystify explicitly built modules
Explore how builds are changing in Xcode 16 with explicitly built modules. Discover how modules are used to build your code, how explicitly built modules improve transparency in compilation tasks, and how you can optimize your build by sharing modules across targets.