You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

报错:../node_modules/react-native中未找到React-Core的podspec(附Podfile)

解决React Native中未找到React-Core podspec的问题

嘿,我来帮你搞定这个Pod依赖报错的问题——这个错误我之前在升级RN版本的时候也碰到过,本质是新版本RN的目录结构和Pod配置逻辑变了,你的配置还停留在老版本的写法上。

问题根源

你看到的在路径../node_modules/react-native中未找到React-Core的podspec错误,是因为React Native 0.60+之后,React-Core.podspec的位置从根目录移到了react-native/React子目录下,而你的Podfile里还是指向了根目录,自然找不到文件。另外,新版本RN也推荐用更简洁的方式配置Pod依赖。

两种修复方案,选一个就行

方案一:适配新版本RN的推荐配置(优先选这个)

直接替换你的Podfile内容为下面的代码,我已经帮你调整了所有路径和配置逻辑,更符合RN新版本的规范:

target 'RNNativeOrientationInteractor' do
  # 如果你不想使用动态框架,请注释下一行
  # use_frameworks!

  # 启用RN的自动链接功能,自动处理第三方模块的Pod依赖
  use_native_modules!

  # 基础React依赖,把所有子模块整合到subspecs里,更清晰
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'DevSupport',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTBlob',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]
  # 修正React-Core的路径,指向正确的子目录
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
end

这里的关键调整:

  • 加了use_native_modules!,不用再手动配置大部分第三方模块的Pod了
  • 把React-Core的路径改成了../node_modules/react-native/React,对应新版本的文件位置
  • 把原来分散的RCT子模块都放到了React的subspecs数组里,更符合官方推荐的写法

方案二:如果你用的是RN 0.59及以下的旧版本

如果你的项目还在使用老版本RN,先检查../node_modules/react-native/React目录下有没有React-Core.podspec文件,如果没有,试试重新安装依赖:

# 回到项目根目录
cd ..
# 删除现有依赖
rm -rf node_modules
# 重新安装npm/yarn依赖
npm install # 用yarn的话就写 yarn install
# 回到ios目录清理并重新安装Pod
cd ios
pod deintegrate
pod install

最后验证一下

不管用哪个方案,修改完Podfile后,记得在ios目录下执行这两步,确保依赖完全生效:

cd ios
pod deintegrate # 彻底清理旧的Pod配置
pod install # 重新安装所有依赖

内容的提问来源于stack exchange,提问作者Artem

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 17:34:09