Cocoapods总是安装旧的React(0.11.0)

Luk*_*lek 7 ios cocoapods react-native

我在运行pod installPod时总是会降级ReactInstalling React 0.11.0 (was 0.55.4)

我的pod文件:

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '9.0'
project 'BunteMobile.xcodeproj'
target 'BunteMobile' do
  # Comment this line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for BunteMobile
  pod 'Adjust', '~> 4.8.3'
  pod 'Google-Mobile-Ads-SDK'
  pod 'GoogleAds-IMA-iOS-SDK', '~> 3.7'
  pod 'Fabric', '~> 1.7.0'
  pod 'Crashlytics', '~>  3.9'

  pod 'lottie-ios', :path => '../node_modules/lottie-ios'

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

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

end
Run Code Online (Sandbox Code Playgroud)

当我从中定义react文件夹时,我读到一些解决方案,node_modules但是该解决方案对我也不起作用。

我将其放入podfile中:

pod 'yoga', path: './node_modules/react-native/ReactCommon/yoga'
pod 'React', :path => '../node_modules/react-native'
Run Code Online (Sandbox Code Playgroud)

但仍然不起作用。降级消失,但是当我尝试构建降级时,出现此错误:

/node_modules/react-native/React/Base/RCTConvert.h:17:9: could not build module 'yoga'
Run Code Online (Sandbox Code Playgroud)

我尝试了与官方RN文档相同的配置文件(https://facebook.github.io/react-native/docs/integration-with-existing-apps.html),但仍然存在相同的错误。


我将此添加到我的podfile中:

# Pods for React-Native start
  pod 'React', :path => '../node_modules/react-native'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
Run Code Online (Sandbox Code Playgroud)

von*_*vak 0

如果您要将 RN 集成到现有的本机应用程序中,您将希望您的 podfile 大致如下所示。也就是说,您将通过以下方式指定 React 依赖项的路径pod 'React', :path => '../node_modules/react-native' ...

您正在开发新的 RN 应用程序吗?如果是这样,您可能不想将其包含pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'在 podfile 中,因为它可能会导致您遇到麻烦。

相反,返回到运行之前您的存储库的样子react-native link lottie-react-native。此命令可能会将该pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'行添加到您的 podfile 中。现在,您可以按照手动安装说明进行操作(我看到不存在,但您可以检查这些,这将是相同的事情),或者您可以执行以下操作:lottie-react-native.podspec从中删除node_modules/lottie-react-native,然后才运行react-native link lottie-react-native。依赖项不会添加到 podfile 中,而是作为静态库链接到二进制文件中。