[REGRESSION] Xcode 9 PrecompileSwiftBridgingHeader failed with a nonzero exit code

Originator:nicholas.helke
Number:rdar://32810754 Date Originated:2017-06-16
Status:Closed Resolved:July 21 2017
Product:Developer Tools Product Version:Fails with Xcode 9 beta (9M136h)
Classification:Serious Bug Reproducible:Always
 
Summary:
Project compiles fine on Xcode 8, fails on Xcode 9 beta (9M136h) with:

Bridge.h:11:9: error: module 'TheModule' not found
@import TheModule;
        ^
1 error generated.
<unknown>:0: error: failed to emit precompiled header '/var/folders/xx/xxxxxx/T/Bridge-812a0f.pch' for bridging header 'Bridge.h'
Command PrecompileSwiftBridgingHeader failed with a nonzero exit code

The project links with theModule.a and has the following module.modulemap file:

module TheModule {
  header "module.h"
  export *
}

Both new and old build systems fail.

Attached is example project which works with Xcode 8 but fails with Xcode 9.

Steps to Reproduce:
Swift Xcode project with a bridging header importing a module defined in a modulemap file from a header for a ObjC based static library.

Expected Results:
Should build, as it does with Xcode 8

Observed Results:
Fails with "Command PrecompileSwiftBridgingHeader failed with a nonzero exit code"

Version:
Fails with Xcode 9 beta (9M136h)

Succeeds with any version of Xcode 8

Comments

Xcode9 does not use SWIFT_PRECOMPILE_BRIDGING_HEADER

Hi Nicholas,

I am not sure if its related but couldn't find any other thread with this issue.

Have checked that this new Build setting (SWIFT_PRECOMPILE_BRIDGING_HEADER) helps in faster builds from Xcode Release notes - https://developer.apple.com/library/content/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html

It works well on a new project. But it doesn't work in my old project when i try to see the build log i don't see the step of "Precompile bridging header" which happens in newer projects. I have checked the build settings and its set to YES.

Could you please help me solve this. It kind of makes the build every time even with no change in code or storyboard.

Thanks, Shahid.

By s.shahidmd at March 1, 2018, 11:04 p.m. (reply...)

Thank you for the well-reduced test case! When precompiling a bridging header, the Swift compiler will no longer automatically read a module map file that's in the same directory as the bridging header. If reading a module map from this directory is important, you can add it as an explicit search path under the "User Header Search Paths" build setting.

By nicholas.helke at July 21, 2017, 11:37 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!