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

React Native v0.73.5集成NavigationContainer后iOS编译失败求助

解决React Native 0.73.5 iOS导航组件编译失败问题

正确的导航依赖安装流程

针对RN 0.73.5,按以下步骤安装导航组件,避免版本冲突:

  • 确保基础项目可正常运行,执行以下命令安装核心依赖:
    npm install @react-navigation/native react-native-screens react-native-safe-area-context @react-navigation/native-stack
    
  • 进入iOS目录更新Pods:
    cd ios && pod install --repo-update
    
    (M1/M2芯片Mac需兼容Rosetta时,执行arch -x86_64 pod install --repo-update)

编译失败问题修复步骤

1. 彻底清理项目残留

执行以下命令清理缓存和冲突文件:

# 根目录操作
rm -rf node_modules package-lock.json
npx react-native clean

# iOS目录操作
cd ios
rm -rf Podfile.lock Pods
xcodebuild clean
rm -rf ~/Library/Developer/Xcode/DerivedData

2. 重新安装依赖与Pods

# 根目录重装依赖
npm install

# iOS目录重装Pods
cd ios && pod install --repo-update

3. 针对性解决组件编译报错

  • RNScreens编译失败:检查Xcode项目的iOS Deployment Target是否≥13.0(RN 0.73强制要求),确保react-native-screens版本与RN兼容(推荐3.29.0)。
  • RNReanimated编译失败:确保Podfile中启用Hermes(RN 0.73默认开启),Podfile关键配置如下:
    use_react_native!(:path => config["reactNativePath"], :hermes_enabled => true)
    
    确认后重新执行pod install。

4. 解决npm start输入i卡住问题

  • 先重置Metro缓存:
    npx react-native start --reset-cache
    
  • 保持Metro运行,新开终端执行npx react-native run-ios,避免直接在Metro中输入i启动。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 02:27:16