React Native 0.74.2升级后pod install报错及构建失败求助
React Native 0.74.2升级后pod install报错及构建失败解决方案
问题核心原因
你碰到的undefined method 'path' for nil:NilClass报错,是因为React Native 0.74+版本对react_native_post_install方法的参数做了调整——不再需要手动传入config[:reactNativePath],这个参数现在会自动读取,手动传递反而会导致nil值触发错误。后续的RCTAppDelegate.h not found、Pods头文件缺失、无Podfile.lock生成,都是因为pod install未成功完成,依赖没有正确安装导致的连锁问题。
具体解决步骤
1. 修正post_install脚本
把你的post_install代码改成0.74+版本要求的格式,移除多余的config[:reactNativePath]参数:
post_install do |installer| react_native_post_install( installer, :mac_catalyst_enabled => false, # :ccache_enabled => true ) end
2. 清理缓存并重新安装依赖
执行以下命令彻底清理残留文件后重新安装:
- 删除Pods相关残留:
rm -rf ios/Pods ios/Podfile.lock rm -rf ~/Library/Caches/CocoaPods rm -rf ios/build
- 重新执行pod install:
cd ios && pod install
3. 验证修复效果
完成后检查以下几点:
- 是否生成了
Podfile.lock文件 Pods/headers/React-Core目录是否存在- 重新运行项目,确认
RCTAppDelegate.h not found错误消失
内容的提问来源于stack exchange,提问作者Irfan wani
相关产品推荐
相关产品推荐

