redefinition of module error since Xcode 8.3

Since I updated to xcode 8.3 I can't compile my project, it was compiling fine with the previous version of xcode. It contains a framework and it now fails to compile the framework.


It fails with many errors about redefined module like so:


/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/module.modulemap:1:8: error: redefinition of module 'AppleTextureEncoder'
module AppleTextureEncoder [system] [extern_c] {
       ^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/usr/include/module.modulemap:1:8: note: previously defined here
module AppleTextureEncoder [system] [extern_c] {


These are not my modules.


I saw the release note mentioning something related, but I do not understand how to apply the work around. My project has no module map file defined in the setting, what should I rename it to? The error points to xcode own modules, so I am confused.


I haven't been able to compile any of my project since xcode 8.3 as they all show the same error... My project and framework mix objective c and swift 3.0


thanks!


Known Issues

When building a framework that has module maps in both the source and the install directories that define the same module, the compiler will show a redefinition message. (28638816)Workaround: Rename the module map file in the source directory to a non-default name (the default name is

module.modulemap
or
module.map
), and set the Module Map File build setting to the renamed module map.

Replies

Same issue with xcode 8.3.1 😟

I don't think that Xcode fix has anything to do with your problem, since you don't declare your own module maps.


Instead, it looks like your target is being linked against both the iOS device and iOS simulator libraries, and you're probably going to have to a bit of detective work on your project to figure out why. Note that it could be there was always something wrong with your project, but Xcode didn't care before 8.3, or it could be that when Xcode updated your project for 8.3 it did something wrong.


Look in the General tab of the project editor, and see if there's anything odd there. (It shouldn't list any system frameworks, because these are found automatically these day, I believe.) Also check the Build Phases tab, especially the Link With Binaries phase. Also check the framework and include path build settings. Sometimes Xcode will migrate an old unwanted path into one of those.

Thanks a lot.


I have been doing quite a bit of investigative work on the project settingsm and comparing with a fresh new project settings, but didn't figure it out yet. I noticed also that it actually compiles if I choose an iOS device, but only fails against the simulator.


I recreated the whole project from scratch in xcode 8.3.2, reimporting the source code manually and using fresh default settings. Interestingly the new project compile now against the simulator but fails against iOS (with the same redefinition error).


I also tried to study the command line that fails (and my environment variables) for any hints to ios reference but to no avail. Here is the full command line


/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/brice/Development/xcode/RZUtils/src/universal/swift/RZSLog.swift -target x86_64-apple-ios9.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -I /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Products/Debug-iphonesimulator -F /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Products/Debug-iphonesimulator -enable-testing -g -import-underlying-module -module-cache-path /Users/brice/Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/RZUtils-generated-files.hmap -Xcc -I/Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/RZUtils-own-target-headers.hmap -Xcc -I/Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/RZUtils-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/RZUtils-project-headers.hmap -Xcc -I/Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/DerivedSources/x86_64 -Xcc -I/Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DGC_IOS=1 -Xcc -ivfsoverlay -Xcc /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/brice/Development/xcode/RZUtils -emit-module-doc-path /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/Objects-normal/x86_64/RZSLog~partial.swiftdoc -serialize-diagnostics-path /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/Objects-normal/x86_64/RZSLog.dia -Onone -parse-as-library -module-name RZUtils -emit-module-path /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/Objects-normal/x86_64/RZSLog~partial.swiftmodule -emit-dependencies-path /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/Objects-normal/x86_64/RZSLog.d -emit-reference-dependencies-path /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/Objects-normal/x86_64/RZSLog.swiftdeps -o /Users/brice/Library/Developer/Xcode/DerivedData/GarminConnect-dxmvrwpwzpqxffggolvmfzhyupdx/Build/Intermediates/RZUtils.build/Debug-iphonesimulator/RZUtils.build/Objects-normal/x86_64/RZSLog.o


/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/module.modulemap:1:8: error: redefinition of module 'AppleTextureEncoder'

module AppleTextureEncoder [system] [extern_c] {

^

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/usr/include/module.modulemap:1:8: note: previously defined here

module AppleTextureEncoder [system] [extern_c] {

^

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/module.modulemap:7:8: error: redefinition of module 'Compression'

module Compression [system] [extern_c] {

^

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/usr/include/module.modulemap:7:8: note: previously defined here

module Compression [system] [extern_c] {

From your transcript:


-module-cache-path /Users/brice/Library/Developer/Xcode/DerivedData/ModuleCache


Have you tried deleting this folder? Note that everything in DerivedData is in theory re-creatable (at the expense of more build time at the point of re-creation).


Also, what is RZUtils? A framework? A static library? How you get it into your build? Note that if your main target relies on libraries that you've added to the target (e.g. in the General tab of the project info), you should check that its path is "relative to build products", rather than relative to a specific build folder. That could explain why same-named modules are being dragged in from different places.


Also, if RZUtils defines its own module map "manually", even though you didn't do it, I suppose it's possible that that subsystem ran afoul of the Xcode bug you mentioned earlier. If that's the case, something in that project (GarminConnect?) may need to have the workaround applied. If this is code from a 3rd party, you might need to get them to fix it.

Hi, First, I just want to mention I really appreciate you helping me! Thanks a lot.


On your question, I tried to removed the derivedcache, it did not work 😟


RZUtils is a framework, I build, with all the shared component I want to use accros my different app and projects. It contains a few external packages (FMDatabase and LibComponentLogging). The framework contains both objective c and swift code. When I remove the swift code for the library it then compiles, so the problem is clearly mixing the two. I have build the framework quite a few generation of xcode ago, so the settings went through a few iteration of xcode update settings. GarminConnect is just one example of an app that include that framework and uses it. But all the app have the same problem.


I tried to recreate the framework from scratch by re-adding the source code to a fresh new xcode 8.3.2 framework project and it resulted in the same problem (though inverted; could compile on simulator but had redefinition error on ios built...)


What I will try today is to rebuild the framework more incrementally adding a few sources at a time see when it starts failing. (the freshly created framework of course compiles on both target)


Also I can share a sample small app trying to use the framework if you want to take a look.

Final update. I have recreated the framework project from scratch step by step and split the swift library from the objective c library.


It works now. I am not going to try further to fix the original process. Wasted a few hours, but glad it works again!