Search code examples
swiftobjective-ccocoapods

How to resolve Objective-C Pods compatibility header conflict - "different definitions in different modules"?


I have two cocoapods in my Xcode project that have a conflict in the generated Objective C header file, resulting in this error:

InputBarAccessoryView/InputBarAccessoryView.framework/Headers/InputBarAccessoryView-Swift.h:413:58: 'InputTextView' has different definitions in different modules; first difference is definition in module 'InputBarAccessoryView.Swift' found property

I am able to resolve this conflict by going into the build settings for the given pod and setting Install Objective-C compatibility header to No

Is there a way for me to specify this setting in the podfile or somewhere else so everyone working on this project will not have to go to their build settings in order to resolve this conflict?

XCode pod build settings


Solution

  • In order to toggle post install build settings for pods do the following in the Podfile

    Get the build_setting name by holding Option and double clicking the name of the setting in Pods.xcodeproj

    To specify settings for all pods in the project

    post_install do |installer|
    
      installer.pods_project.build_configuration_list.build_configurations.each do |configuration|
          configuration.build_settings['Setting you want to toggle'] = 'YES'
      end 
    end
    

    To specify setting for a specific pod

    post_install do |installer|
    
      installer.pods_project.targets.each do |target|
        
        if target.name === "Specific Pod Name"
          target.build_configurations.each do |config|
            config.build_settings['SWIFT_INSTALL_OBJC_HEADER'] = 'NO'
          end
        end
      end
    end