Redefinition of module 'React' in React-RCTWebSocket.modulemap

Viewed 1166

Good day,

We have just upgraded react-native from 0.59.10 to 0.60.0. Mainly we have been following these guides:

https://react-native-community.github.io/upgrade-helper/?from=0.59.10&to=0.60.0

https://mattoakes.net/react-native-upgrade-guides/upgrade-to-react-native-0.60

When it comes to Android, the upgrade process was pretty straight-forward. But my team is struggling quite a bit when doing the iOS side.

After following those guides and solve some problems, we are facing one which we can not find any info about... We have been stuck in here for a while now.

So, the problem is: when we build the project, the next error appears. ERROR IMAGE

Reading about some similar topics, other people of the community suggested that we may be adding the same package twice either in the Build Settings or the Build Phases in our target in the XCode project. But I can not find any of it :/

I suspect that the error comes form our Podfile, but it looks good to me:

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

use_modular_headers!

def pods()
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec', :modular_headers => false
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec', :modular_headers => false
end

target 'OneSignalNotificationServiceExtension' do
  # Pods for OneSignalNotificationServiceExtension
  use_native_modules!
end

target 'XXX' do
  # Pods for xxx
  pods()
  
  target 'XXXTests' do
    inherit! :search_paths
    # Pods for testing
  end
  
  use_native_modules!

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
      end
    end
  end

end

That's it, can anyone help us?

If there is anything you want me to attach in order to have more info about the error, do not hesitate to ask.

All advice is welcome :)

1 Answers

I had this same issue with a package in my pods requiring i use the use_modular_headers! setting.

This seems to cause conflicts in the react modules as its defining react twice. The fix for me was to add :modular_headers => false after each react package in the podfile. Here is my podfile for react version 0.60.6 as an example.

target ‘app’ do
  use_modular_headers!
  # Pods for RNDiffapp
  pod ‘React’, :path => ‘../node_modules/react-native/’
  pod ‘React-Core’, :path => ‘../node_modules/react-native/React’
  pod ‘React-DevSupport’, :path => ‘../node_modules/react-native/React’, :modular_headers => false
  pod ‘React-RCTActionSheet’, :path => ‘../node_modules/react-native/Libraries/ActionSheetIOS’, :modular_headers => false
  pod ‘React-RCTAnimation’, :path => ‘../node_modules/react-native/Libraries/NativeAnimation’, :modular_headers => false
  pod ‘React-RCTBlob’, :path => ‘../node_modules/react-native/Libraries/Blob’, :modular_headers => false
  pod ‘React-RCTImage’, :path => ‘../node_modules/react-native/Libraries/Image’, :modular_headers => false
  pod ‘React-RCTLinking’, :path => ‘../node_modules/react-native/Libraries/LinkingIOS’, :modular_headers => false
  pod ‘React-RCTNetwork’, :path => ‘../node_modules/react-native/Libraries/Network’, :modular_headers => false
  pod ‘React-RCTSettings’, :path => ‘../node_modules/react-native/Libraries/Settings’, :modular_headers => false
  pod ‘React-RCTText’, :path => ‘../node_modules/react-native/Libraries/Text’, :modular_headers => false
  pod ‘React-RCTVibration’, :path => ‘../node_modules/react-native/Libraries/Vibration’, :modular_headers => false
  pod ‘React-RCTWebSocket’, :path => ‘../node_modules/react-native/Libraries/WebSocket’, :modular_headers => false
  pod ‘React-cxxreact’, :path => ‘../node_modules/react-native/ReactCommon/cxxreact’, :modular_headers => false
  pod ‘React-jsi’, :path => ‘../node_modules/react-native/ReactCommon/jsi’, :modular_headers => false
  pod ‘React-jsiexecutor’, :path => ‘../node_modules/react-native/ReactCommon/jsiexecutor’, :modular_headers => false
  pod ‘React-jsinspector’, :path => ‘../node_modules/react-native/ReactCommon/jsinspector’, :modular_headers => false
  pod ‘yoga’, :path => ‘../node_modules/react-native/ReactCommon/yoga’, :modular_headers => false
  pod ‘DoubleConversion’, :podspec => ‘../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec’, :modular_headers => false
  pod ‘glog’, :podspec => ‘../node_modules/react-native/third-party-podspecs/glog.podspec’, :modular_headers => false
  pod ‘Folly’, :podspec => ‘../node_modules/react-native/third-party-podspecs/Folly.podspec’, :modular_headers => false

I left out React and React-Core as these are the modules being redefiend in the first place.

Related