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

升级React Native到0.74后React-Fabric编译失败求助

解决React Native 0.74.5 iOS构建失败:RNCheck rncore路径不存在问题

问题概述

升级旧项目适配iOS新版本,完成npm更新与React Native升级到0.74.5后,pod install执行成功,但运行run-ios时构建失败,报错:

The following build commands failed:
PhaseScriptExecution [CP-User]\ [RN]Check\ rncore .../Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-Fabric.build/Script-EC9C377125AD0589400F123D2D4CB2D3.sh (in target 'React-Fabric' from project 'Pods')

深入排查发现,失败的构建脚本会检查$REACT_NATIVE_PATH/ReactCommon/react/renderer/components/rncore路径是否存在,而该路径缺失。

环境信息

info Fetching system and libraries information...
System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M3
  Memory: 82.38 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.16.0
    path: ~/.nvm/versions/node/v20.16.0/bin/node
  Yarn: Not Found
  npm:
    version: 10.8.1
    path: ~/.nvm/versions/node/v20.16.0/bin/npm
  Watchman:
    version: 2024.07.29.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/lib/ruby/gems/3.3.0/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12071903
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 3.3.4
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.5
    wanted: 0.74.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: false
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: false

解决步骤

1. 修复React Native依赖完整性

  • 删除node_modules并重新安装依赖:
rm -rf node_modules
npm install
  • 清理npm缓存,避免缓存导致的安装异常:
npm cache clean --force

2. 重新执行Codegen并重装CocoaPods

脚本提示Codegen未正确运行,按以下流程操作:

  • 清理iOS目录下的Pods相关文件:
cd ios
rm -rf Pods Podfile.lock build
  • 回到项目根目录,手动触发Codegen(0.70+版本通常自动执行,若缺失可手动运行):
npx react-native codegen
  • 重新安装Pods:
cd ios
# 若项目使用Bundle管理Ruby版本,执行 bundle exec pod install,否则直接运行
pod install

3. 校验REACT_NATIVE_PATH变量

  • 打开iOS项目的Pods/Target Support Files/React-Fabric/React-Fabric.debug.xcconfig(或Release版本对应文件),确认REACT_NATIVE_PATH指向正确路径,应为${SRCROOT}/../node_modules/react-native。若路径错误,修正后重新执行pod install。

4. 清理Xcode缓存

  • 在Xcode中按Cmd+Shift+K清理构建缓存,再按Cmd+Option+Shift+K清理DerivedData;
  • 或手动删除DerivedData目录:
rm -rf ~/Library/Developer/Xcode/DerivedData

5. 确认rncore目录存在

  • 检查node_modules/react-native/ReactCommon/react/renderer/components/下是否有rncore目录。若不存在,说明npm安装不完整,重新执行npm install并查看安装日志是否有报错(比如网络问题导致依赖下载中断)。

6. 调整CocoaPods版本(可选)

React Native 0.74.x兼容CocoaPods 1.14.x-1.15.x,当前1.15.2版本没问题,若仍有异常,可尝试降级到1.14.3:

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.14.3

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 21:22:25