Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Precompile bridging header and compilation of any swift files that import that import my objective-c framework with modulemap runs every build

I have a project which is set up like so

App.xcproject
   App target { Dependency on Bridges.framework }
Bridges.xcproject 
   Bridges.framework

Bridges.framework has a bunch of Objective-c++ headers that import c++ headers/frameworks etc. It has a modulemap that allows it to generate bridging headers for the App target which is Swift only.

I have noticed that every single build Planning Swift module App is run for 1 second, then Precompile bridging header is run for a moment, then every single swift file that imports Bridges recompiles regardless of if it had any edits taking about 2-3 seconds.

It feels like since nothing has changed inside of Bridges that this bridging header precompile should not be necessary every single run.

  • Bridges.framework is in General/Frameworks as "Do not embed"
  • Bridges is in build phases "Target dependencies" and "Link binary with libraries"

Is this just normal and I should let this slide or is there a way to avoid this?

Answered by Developer Tools Engineer in 843557022

Thanks for the feedback. It will be good if you can file a feedback report with a reproducer so we can take a look.

This is some information that help you debug:

  • If nothing really changed in your framework, build system should not run Planning job and it should be null build.
  • You can add flag -driver-show-incremental to OTHER_SWIFT_FLAGS and you can see how swift driver reasons about incremental build in Planning job output
  • swift-driver today doesn't check if PCH file is up-to-date (yes, please file feedback report or file issue on swift-driver GitHub), but that shouldn't affect incremental build for the individual swift files
  • In your case, it might be helpful to write a module map that turns your bridging header and everything it includes into an appropriate module. Then you get better dependency tracking and sharing in this case.
Accepted Answer

Thanks for the feedback. It will be good if you can file a feedback report with a reproducer so we can take a look.

This is some information that help you debug:

  • If nothing really changed in your framework, build system should not run Planning job and it should be null build.
  • You can add flag -driver-show-incremental to OTHER_SWIFT_FLAGS and you can see how swift driver reasons about incremental build in Planning job output
  • swift-driver today doesn't check if PCH file is up-to-date (yes, please file feedback report or file issue on swift-driver GitHub), but that shouldn't affect incremental build for the individual swift files
  • In your case, it might be helpful to write a module map that turns your bridging header and everything it includes into an appropriate module. Then you get better dependency tracking and sharing in this case.

Sounds good! Will try and catch it.

Precompile bridging header and compilation of any swift files that import that import my objective-c framework with modulemap runs every build
 
 
Q