M1 Mac Ventura下React Native初始化后pod install安装glog(0.3.5)失败
React Native iOS环境glog(0.3.5)安装失败的解决办法
方案1:手动替换glog的config.sub文件
- 从
pod install的报错信息中找到glog的临时安装路径(通常类似~/Library/Caches/CocoaPods/Pods/Release/glog/0.3.5-xxxx) - 进入该路径,执行以下命令下载并替换最新的
config.sub文件:curl -O https://raw.githubusercontent.com/llvm-mirror/llvm/master/config/config.sub - 重新执行
pod install
方案2:通过Podfile预脚本自动替换文件
- 在iOS目录的
Podfile最顶部添加以下预安装脚本:pre_install do |installer| installer.pod_targets.each do |target| next unless target.name == 'glog' config_sub_path = "#{target.root}/config.sub" system("curl -O https://raw.githubusercontent.com/llvm-mirror/llvm/master/config/config.sub") system("mv config.sub #{config_sub_path}") end end - 保存后重新执行
pod install
方案3:清理CocoaPods缓存后重装
- 清理所有CocoaPods缓存:
pod cache clean --all - 删除iOS目录下的
Podfile.lock文件和Pods文件夹 - 针对M系列芯片Mac,执行:
arch -x86_64 pod install
方案4:校验Xcode命令行工具配置
- 打开Xcode,进入
偏好设置 > 位置,确认命令行工具选择的是当前安装的Xcode版本 - 执行以下命令验证路径正确性:
确保输出为xcode-select --print-path/Applications/Xcode.app/Contents/Developer
方案5:降级CocoaPods版本
- 卸载当前CocoaPods:
gem uninstall cocoapods - 安装兼容性更好的旧版本(如1.11.3):
gem install cocoapods -v 1.11.3 - 重新执行
pod install
内容的提问来源于stack exchange,提问作者Eric V
相关产品推荐
相关产品推荐

