Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native: Podfiles causing name collusions

I am getting an error:

Ambiguous resolution: module ".../myModule.js" tries to require 'react-native', but there are several files providing this module. You can delete or fix them:

.../MyProject/ios/Pods/React/package.json

.../MyProject/node_modules/react-native/package.json

I am almost certain that this is due to using Podfiles, specifically, when they install the "React" folder. However, I had to use Podfiles in order to install react-native-firebase. With that said, when I delete the React folder under my Pods folder (ios/Pods/React), I can no longer use react-native-firebase.

There was a fix floating around GitHub, which suggested appending the Podfile with:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end

But this did not work for me. Has anyone encountered this problem before?

If it is relevant, this is the podfile that I am using:

platform :ios, '8.0'

target 'MyProject2' do
    pod 'Firebase/Core'
    pod 'Firebase/Database'
    pod 'Firebase/Messaging'

  pod 'RNSVG', :path => '../node_modules/react-native-svg'

  target 'MyProject2Tests' do
    inherit! :search_paths
    # Pods for testing
  end

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end
    end
  end

end

EDIT: When I remove the 'RNSVG' from my Podfile, I get an error stating: "Invariant Violation: Native component for 'RNSVGPath' does not exist". I have both ran react-native link and followed the instructions for manual installation for react-native-svg.

like image 682
user8951490 Avatar asked Nov 17 '22 17:11

user8951490


1 Answers

I had to manually link the React pod to node_modules:

pod 'React', :path => '../node_modules/react-native'

like image 180
Chris Feist Avatar answered Dec 14 '22 23:12

Chris Feist