What’s explicitly built modules?
Generated on 8/2/2024
1 search
Explicitly built modules are a new way of handling module builds in Xcode, introduced to improve the build process for Swift and Clang modules. Here are the key points about explicitly built modules:
-
Build System Control: Explicitly built modules put the build system in control of module builds. This means that the build system explicitly manages the tasks of scanning, building modules, and compiling the original code, rather than these tasks being implicitly handled by the compiler.
-
Build Phases: The compilation of each source file is split into three separate phases:
- Scanning: Xcode scans each source file to build a module graph for the entire project.
- Building Modules: Modules are compiled as explicit tasks in the build log.
- Building Original Code: The original source files are compiled, now with the compiled modules they depend on.
-
Build Logs and Timeline: The build logs now show separate tasks for scanning and module compilation, providing a clearer breakdown of the build process. This helps in better parallelism and clearer error messages if the build fails due to a module issue. The build timeline view also reflects these explicit tasks, making it easier to see where time is being spent.
-
Efficiency and Reliability: By making the build system aware of modules, it can avoid running tasks that are not ready, leading to more efficient use of execution lanes. This results in more reliable builds with precise dependencies and deterministic build graphs. The build system can also make more informed scheduling choices, reducing the number of module variants that get built.
-
Debugging Improvements: Explicitly built modules make debugging faster because the debugger can reuse the build outputs when evaluating expressions. This avoids the need for the debugger to build its own version of module files, leading to faster debugging.
-
Enabling Explicitly Built Modules: In Xcode 16, explicitly built modules are used for all C and Objective-C code and can be enabled as a preview for Swift. This can be done by selecting the project in the project navigator, going to build settings, and setting the "Explicitly Built Modules" option to "Yes".
For more detailed information, you can refer to the session Demystify explicitly built modules (05:55).
Relevant Sessions
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.
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.
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.