RN pod install 失败(could not find compatible versions for pod “React/Core“)

2022-07-29,,,,

使用最新版本 React-Native(0.63) 准备嵌入原生项目时, 按照官网教程集成到现有原生项目, 一步一个脚印, 到 pod install 出现如下错误

[!] CocoaPods could not find compatible versions for pod "React/Core":
In Podfile:
React/Core (from `../node_modules/react-native`)

None of your spec sources contain a spec satisfying the dependency: `React/Core (from `../node_modules/react-native`)`.

You have either:
* out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.

最后的最后发现时 Podfile 的写法需要替换了,不同版本有不同写法。

在官方 github/template/ios/Podfile 寻找对应版本的 Podfile 写法。就可以 pod install成功了。比如0.63.1 Podfile

写入如下:

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

platform :ios, '10.0'

target 'HelloWorld' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  target 'HelloWorldTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'HelloWorld-tvOS' do
  # Pods for HelloWorld-tvOS

  target 'HelloWorld-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

本文地址:https://blog.csdn.net/qq_14920635/article/details/108584151

《RN pod install 失败(could not find compatible versions for pod “React/Core“).doc》

下载本文的Word格式文档,以方便收藏与打印。