【问题标题】:CocoaPods could not find compatible versions for pod "React/Core"?CocoaPods 找不到 pod "React/Core" 的兼容版本?
【发布时间】:2021-03-31 00:12:27
【问题描述】:

按照链接中的步骤将 react native 集成到现有项目中没有帮助。

链接: https://reactnative.dev/docs/integration-with-existing-apps

配置

Mac OS X - 10.15.6 (19G2021)
XCode - 12.1 (12A7403)
React Native Cli - 2.0.1
React Native - 0.63.4

package.json

{
  "name": "MyReactNativeApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "yarn react-native start"
  }
  "dependencies": {
    "react-native": "^0.63.4"
  }
}

Podfile

source 'https://github.com/CocoaPods/Specs.git'

# Required for Swift apps
platform :ios, '11.0'
use_frameworks!

# The target name is most likely the name of your project.
target 'MyReactNativeApp' do
  
  # Your 'node_modules' directory is probably in the root of your project,
  # but if not, adjust the `:path` accordingly
  pod 'React', :path => '../MyReactNativeApp/node_modules/react-native', :subspecs => [
  'Core',
  'CxxBridge', # Include this for RN >= 0.47
  'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
  'RCTText',
  'RCTNetwork',
  'RCTWebSocket', # needed for debugging
  # Add any other subspecs you want to use in your project
  ]
  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod "Yoga", :path => "../MyReactNativeApp/node_modules/react-native/ReactCommon/yoga"
  
  # Third party deps podspec link
  pod 'DoubleConversion', :podspec => '../MyReactNativeApp/node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../MyReactNativeApp/node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../MyReactNativeApp/node_modules/react-native/third-party-podspecs/Folly.podspec'
  
end

当我运行 pod install 时。我收到一个错误

[!] CocoaPods could not find compatible versions for pod "React/Core":

截图:

我检查了现有的线程。没有什么可以正常工作。我还做了 pod 'React' 移除了其他所有东西,结果是

  1. 已弃用
  2. 它未被检测为模块。未找到模块 - 我 将为此分开问题。

【问题讨论】:

  • 你试过pod update吗?
  • 是的,我试过了,但没用。
  • 为什么不在安装前检查它的兼容性?
  • 按照官方文档中的说明完成。如果我确实删除它们或更改兼容性,则会出现其他问题。我发布了另一个问题,其中我删除了所有子规范并使用了 React,其中提到了它已被弃用,并带有相应的错误。 @ElTomato
  • 糟糕...这是我的误会。我以为您正在尝试将其用于 macOS。对此我很抱歉。

标签: ios swift react-native


【解决方案1】:

按照以下步骤操作。这可能会有所帮助。

  • 在 XCode 中打开您的项目。
  • 展开Pods文件。
  • 应该有Development Pods,也展开。
  • 找到React 文件夹。应该有 2 个文件夹:PodsSupport Files。转到Pods 文件夹。
  • 这个目录应该包含React.podspec文件,打开它,找到s.dependency "React/Core",在哪里,改成s.dependency "React-Core",

【讨论】:

  • 在 pod install 命令期间出现此错误。不会生成 Pod 文件夹。我正在尝试添加到现有项目中。请重新审视问题。
  • 如果你的意思是改变内部的反应模块,问题是为什么官方 repo 中的这个库对于新版本不存在。我这样做了,但随后会导致更多问题
  • 目前它的 s.dependency "React-Core",版本
  • 当 pod install 检测到“React/Core”时:
  • 当我做 pod 'React', :path => '../MyReactNativeApp/node_modules/react-native' pod 'React-Core', :path => '../MyReactNativeApp/node_modules /react-native' 它说 [!] 无法找到 React-RCTActionSheet (= 0.63.4) 的规范,这取决于 React
猜你喜欢
  • 2020-10-19
  • 2021-03-19
  • 2022-11-04
  • 2021-10-31
  • 1970-01-01
  • 2019-02-23
  • 2022-07-03
  • 1970-01-01
相关资源
最近更新 更多