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

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 17:15:07