React Native:Podfiles导致名称共谋

use*_*490 5 cocoapods reactjs react-native react-native-firebase

我收到一个错误:

模糊解析:模块".../myModule.js"尝试要求'react-native',但有几个文件提供此模块.您可以删除或修复它们:

.../MyProject的/ IOS /荚/反应,和/的package.json

.../MyProject的/ node_modules /反应原生/的package.json

我几乎可以肯定这是因为使用Podfiles,特别是当他们安装"React"文件夹时.但是,我必须使用Podfiles才能安装react-native-firebase.话虽如此,当我删除我的Pods文件夹下的React文件夹(ios/Pods/React)时,我再也无法使用了react-native-firebase.

GitHub周围有一个修复程序,建议在Podfile中附加:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

但这对我不起作用.以前有人遇到过这个问题吗?

如果它是相关的,这是我正在使用的podfile:

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
Run Code Online (Sandbox Code Playgroud)

编辑:当我从我的Podfile中删除'RNSVG'时,我收到一条错误消息:"不变违规:'RNSVGPath'的原生组件不存在".我已经运行react-native链接并按照手动安装的说明进行操作react-native-svg.

小智 -1

看一下react-native-svg,他们的 Podfile 将 React 指定为依赖项。为了简单起见,我建议您使用推荐的react-native link命令来安装这个库,而不是在 Podfile 中指定它。

删除后,react-native-svg您可能需要清除Podfile文件夹并重新运行pod install