React Native项目构建失败:AndroidManifest缺包名及Podfile错误求助
执行npm/pod install后,/Users/runner/work/1/s/node_modules/react-native-image-picker/android/src/main/AndroidManifest.xml文件缺失包名,本地手动添加后流水线构建仍失败。
复现步骤
- 执行
npm install - 执行
pod install
配置信息
- "react-native": "0.70.5"
- "react-native-image-picker": "^5.6.0"
补充报错信息
[!] Invalid
Podfilefile: 809: unexpected token at 'info Run CLI with --verbose flag for more details.from /Users/runner/work/1/s/ios/Podfile:20
target 'Proxus' do
config = use_native_modules!The process '/usr/local/lib/ruby/gems/3.0.0/bin/pod' failed with exit code 1
The 'pod' command failed with error: The process '/usr/local/lib/ruby/gems/3.0.0/bin/pod' failed with exit code 1
解决建议
修复Podfile语法问题
报错明确指向Podfile第20行存在意外token,检查use_native_modules!的调用是否规范,或者Podfile中是否有括号不匹配、多余字符等语法错误。可以参考React Native 0.70官方Podfile模板调整。用补丁替代手动修改node_modules
流水线构建时会重新执行npm install,手动修改的node_modules文件会被覆盖,根本解决方法是用patch-package打补丁:- 本地修改
node_modules/react-native-image-picker/android/src/main/AndroidManifest.xml补充包名 - 执行
npx patch-package react-native-image-picker生成补丁文件 - 将补丁文件提交到代码仓库,流水线构建时会自动应用补丁
- 本地修改
验证版本兼容性
确认react-native-image-picker@5.6.0是否适配RN 0.70.5,若存在兼容性问题,查看该库的CHANGELOG或GitHub issues,降级到官方标注兼容的版本。清理构建缓存
流水线构建前添加缓存清理步骤:rm -rf node_modules && npm install cd ios && rm -rf Pods Podfile.lock && pod install
内容的提问来源于stack exchange,提问作者Sagar H

