CocoaPods 找不到 pod "ReactCommon/jscallinvoker" 的兼容版本:

CocoaPods could not find compatible versions for pod "ReactCommon/jscallinvoker":

我刚更新到 RN v0.62,iOS 上的 运行 应用程序出现以下错误

!] CocoaPods could not find compatible versions for pod "ReactCommon/jscallinvoker":
  In snapshot (Podfile.lock):
    ReactCommon/jscallinvoker (from `../node_modules/react-native/ReactCommon`)

  In Podfile:
    ReactCommon/jscallinvoker (from `../node_modules/react-native/ReactCommon`)

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

我删除了所有 node_modules 并做了 npm i。我还在 iOS 目录中安装了 pod,但问题仍然存在。我也做了 pod repo 更新。

对于React native0.62版本

所以我想通了

替换 Podfile 中的以下行

pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"

pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"

编辑:

如果您已经更新到 React Native 版本 0.63

从 iOS 文件夹中删除 Podfile.lock。 执行 npm i

从 iOS 文件夹

打开 podfile

删除所有内容并复制以下内容

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

platform :ios, '10.0'

target 'RNTodo' do
  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"])

  target 'RNTodoTests' 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 'RNTodo-tvOS' do
  # Pods for RNTodo-tvOS

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

RNTodo 替换为您自己的项目名称,cd 到终端中的 iOS 文件夹并执行 pod install 一切正常

此外 RN 0.63 已放弃对 iOS 9

的支持

我认为 jscallinvoker 版本已弃用尝试替换

jscallinvoker 

callinvoker

如果你已经有 callinvoker 但你仍然有错误。这种操作帮助了我:

 react-native start --reset-cache
 rm -rf node_modules/
 rm -rf package-lock.json 
 cd ios
 pod deintegrate
 cd ..
 rm -rf ios/Podfile.lock 
 npm install
 npm audit fix
 react-native link
 cd ios
 pod install
 cd ..
 react-native run-ios

如果有人仍然对 React Native 版本 0.63.0 有问题,那么这对我有用

更新 callinvoker pod 如下

pod 'React-callinvoker', :path => "#{rnPrefix}/ReactCommon/callinvoker"

我通过将 Podfile 中的行从

更改为解决了这个问题(版本 0.63)
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"

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

在 RN 0.63.0 中,您可以从 podfile 中删除所有 RN pods,并只在目标中包含以下行。

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

podfile:

开头的platform行之后也需要加这一行
require_relative '../node_modules/react-native/scripts/react_native_pods'

之后,删除Pods 目录、Podfile.lock 和工作区文件。然后 pod install.

React-Native 现在正在动态配置 pods,因此您无需再一一列出;

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

这是您从 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 'test' do
  config = use_native_modules!

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

  target 'testTests' do
    inherit! :complete
  end


  use_flipper!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'test-tvOS' do

  target 'test-tvOSTests' do
    inherit! :search_paths
  end
end

关于升级到 React Native 0.63.0

我的项目在将 React Native 升级到版本 0.63.0 后出现此问题,因此对于解决方案,我只是删除 Podfile.lock 并删除整个 Podfile 并添加来自最新版本的全新安装 React Native 项目的新内容,这意味着它的内容应该是:

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

platform :ios, '10.0'

target '[YourProjectName]' do
  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"])

  target '[YourProjectName]Tests' 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 '[YourProjectName]-tvOS' do
  # Pods for [YourProjectName]-tvOS

  target '[YourProjectName]-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

注意很明显你应该用[YourProjectName]替换你的项目名称。

之后,运行 npx pod-install 在项目的根目录下执行命令,一切都会回到正轨。

根据 https://react-native-community.github.io/upgrade-helper/?from=0.62.2&to=0.63.2 进行手动调整可能会有帮助。

然后您将必须 运行 命令 cd ios && pod install

在将 Expo 裸工作流程 0.38 (RN 0.62) 升级到 0.39(具有 RN 0.63)时遇到此问题。 @Pritish 的编辑答案确实有效,但它说这个 error

[!] Unable to find a target named `RNTodo-tvOS` in project `RNTodo.xcodeproj`, did find `RNTodo`.

[!] Unable to find a target named `RNTodoTests` in project `RNTodo.xcodeproj`, did find `RNTodo`.

通过如下更改 Podfile 获得解决方法

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

platform :ios, '10.0'

target 'daytodiary' do
  use_unimodules!
  config = use_native_modules!
  use_react_native!(:path => config["reactNativePath"])

  # 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

发生了什么变化?

在顶部添加单模块

require_relative '../node_modules/react-native-unimodules/cocoapods.rb'

config = use_native_modules! 之前添加 use_unimodules!

删除

target '[YourProjectName]Tests' do
    inherit! :complete
    # Pods for testing
  end

删除

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

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

对于Android(如果升级后出现错误)

android/build.gradle 变化

ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 21
        compileSdkVersion = 28
        targetSdkVersion = 28
    }

ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 29
    }

RN 0.63 已放弃对 iOS 9

的支持

因此在 pod 文件中 替换

  • 平台:ios, '9.0'*
  • 平台:ios,'10.0'*

  • pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
  • pod 'React-callinvoker', :path => "../node_modules/react-native/ReactCommon/callinvoker"

转到终端中的 ios 文件夹 运行

  • pod 安装
  • 运行 react-native run-ios
platform :ios, '11.0'

我通过如下更改解决了这个问题(版本 0.63.4)

pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"

# Maybe someone is

pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"


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