Search code examples
iosxcodexcode9

"Redefinition of module ..." when building for simulator


I have an iOS xcode project that builds fine when I have Generic iOS Device selected as my destination. However, when I select any of the simulator options I the build fails with many Redefinition of module 'abcde', one error for every module defined in iOS 11.4/usr/include/module.modulemap.

The duplicate definitions are coming from Simulator - iOS 11.4/usr/include/module.modulemap. I've combed through my workspace/project settings and found no reference to the simulator. All the deployment targets are iOS 11.4.

It appears that when I build for the simulator it is including both the platform and simulator modules. How can I specify one or the other?

This problem popped up out of the blue about a day after adding cocoapods and swift code but I don't know if it is related. (The sdk/deployment targets for the pods are also iOS 11.4 and swift version is 4 (except for Socket.IO which is using 3)).

My pods project is using the generated modulemap (I haven't edited it at all):

framework module Pods_MyProjectName {
  umbrella header "Pods-MyProjectName-umbrella.h"

  export *
  module * { export * }
}

I've googled this problem over and over and haven't been able to find any solution for it. I've tried cleaning and rebuilding, deleting the contents of the Library/Developer/Xcode/DerivedData folder, deleting the pod's modulemap file, commenting out each line of the pod's modulemap file, removing all the code written since the problem began... I have the feeling that I'm looking in all the wrong places.


Solution

  • I had the same issue with other pods. I assume the issue has to do with recursive dependecnies that are also imported explicitly. I tried all the same things as you did, although the only thing that helped me was to close xcode, run

    pod deintegrate
    pod install
    

    and rebuild.