Xcode 8.3 beta 1 (8W109m): "Redefinition of module 'ModuleName'" build error

Number:rdar://30194818 Date Originated:25-Jan-2017 02:12 PM
Status:Closed Resolved:20-Apr-2017 02:12 PM
Product:Developer Tools Product Version:Xcode-8.3 (8W109m)
Classification:Other Bug Reproducible:Always
Building an Objective-C project with C, C++, ObjC, ObjC++ sources with a custom module map that previously compiled successfully with Xcode 7.0-8.2.1 fails to compile with Xcode 8.3 beta 1 (8W109m).

Steps to Reproduce:
1. git clone https://github.com/realm/realm-cocoa.git
2. cd realm-cocoa
3. git submodule update --init --recursive
4. git checkout v2.3.0 # optional
5. open -a Xcode-8.3.app .
6. Select the "Realm" scheme with "My Mac" as a build target
7. CMD-B to build

Expected Results:
Should compile successfully.

Actual Results:
Fails to compile with the following error:

/path/to/project/realm-cocoa/Realm/module.modulemap:1:18: error: redefinition of module 'Realm'
framework module Realm {
/Users/me/Library/Developer/Xcode/DerivedData/Realm-fgnurdgvwrgrprepohogrgawtdgm/Build/Intermediates/Realm.build/Debug/Realm.build/module.modulemap:1:18: note: previously defined here
framework module Realm {
1 error generated.

Removing the custom module map from the build settings makes the target compile successfully, but that's not an option for us, since we make use of clang submodules.
Replacing the contents of the custom module map with the contents of the default Xcode-generated modulemap that's produced when removing the custom module map build setting still produces the same error.

Provide additional information, such as references to related problems, workarounds and relevant attachments.


The original report on your issue has been closed recently. Please note that you will not be able to directly view the original report in order to keep its information confidential.

If you have further questions about this issue, please update your report using the Apple Bug Reporter http://bugreport.apple.com.

Engineering has determined that your bug report is a duplicate of another issue and will be closed.

The open or closed status of the original bug report your issue was duplicated to appears in the yellow "Duplicate of 24116019 (Open)" section of the bug reporter user interface. This section appears near the top of the right column's bug detail view just under the bug number, title, state, product and rank.

If you have any questions or concerns, please update your report directly here: http://bugreport.apple.com/.

My comment from Jan 26 11:58am

Note that renaming the module map file to "Realm.modulemap" works around this issue. However, this is still a bug as I don't believe the intent is to require that a modulemap's file name match the module name.

See https://github.com/realm/realm-cocoa/pull/4593 for the fix for our project.

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!