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:
(M1/M2芯片Mac需兼容Rosetta时,执行cd ios && pod install --repo-updatearch -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
相关产品推荐
相关产品推荐

