Xcode build time frustration

We have a Xcode project consisting of:

  • A mix of Swift and Objective-C code app code ~ 1600 source files.
  • Roughly around 35 {XC}Frameworks. Some of them are binary and some of them are getting built as a dependency to our app, etc.
  • Binary libraries.
  • Most of the frameworks built together with app code are Objective-C or Swift-based, which have their own amount of sources files and framework dependencies.
  • The binary frameworks mostly contain cross-platform C++ code.

Our (the poor developers) frustration is that almost all time when we do a insignificant change (or even just tap Cmd-R without any changes) in Swift-file or Objective-C file (.m) and then build again then big sh*t show starts again...

For example:

  • Frameworks may get rebuilt even though they are not touched.
  • Tons of app-level files get built again even though no interface changes, etc. was made.
  • Module verifier keeps verifying modules not touched at all, which takes really long time.
  • Xcode 16 didn't seems to improve the situation - on the contrary.

Example of an untouched framework that for unknown reason goes trough this every time we build:

I know it is hard to come with ideas to solve this for an unknown larger project. But do other people with similar-size projects also experience this or is re-building not an issue for you?

Cheers!

I have the same issue, but since Xcode 16 my build time has increased by A LOT

We have changed our configuration to:

  • Debug: ENABLE_MODULE_VERIFIER = NO
  • Release: ENABLE_MODULE_VERIFIER = YES

Great relief!

Of course with a risk that module verifier first fails when we build a release build.

The module verifier is not expected to run for every incremental build. However, if there is a Run Script build phase with no specified output files that runs on every incremental build, the module verifier will defensively run in case the script modifies any module contents (headers or module maps).

Specifying the input and output files for each Run Script build phase will allow the phase to be skipped in incremental builds when it isn't needed, and thus allow the module verifier to be skipped. https://developer.apple.com/documentation/xcode/running-custom-scripts-during-a-build#Specify-the-input-and-output-files-for-your-script has some details about this.

Where it isn't easy to specify any input or output files, a workaround is to specify a "dummy" output file so that Xcode can know that the Run Script phase doesn't affect the module. Add an output file that is $(DERIVED_FILE_DIR)/NameOfScriptPhase.txt, and at the end of the script add a touch "$DERIVED_FILE_DIR/NameOfScriptPhase.txt". Note that this is not recommended, fully specifying the real input and output files is how to best allow the Xcode build system to schedule and run your Run Script build phase.

Apple is following an issue where building clang modules in C++ language modes is slow. As a temporary workaround, you can also remove c++ and objective-c++ from the MODULE_VERIFIER_SUPPORTED_LANGUAGES build setting in the Debug configuration if the above steps don't help the issue. ENABLE_MODULE_VERIFIER can also be disabled, but that should be the last resort.

I'm seeing this issue despite removing all custom build scripts

Removing "objective-c++" from MODULE_VERIFIER_SUPPORTED_LANGUAGES in each framework made it much faster (44s -> 14s)

But it looks like the verification is still happening each time, it's just faster. I disabled it for the frameworks and gained another 0.5s of build time back.

Xcode build time frustration
 
 
Q