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

iOS Flutter项目安装Firebase v11.2.0时Git克隆RPC失败求助

解决CocoaPods安装Firebase v11.2.0时Git克隆RPC失败的方案

1. 更换Git协议为SSH

HTTP协议克隆大仓库易因网络波动断连,换成SSH协议能提升稳定性:

  • 无SSH密钥则生成:ssh-keygen -t ed25519 -C "your_email@example.com"
  • 将公钥添加到GitHub账户(Firebase相关依赖托管于GitHub)
  • 全局配置Git优先用SSH:
    git config --global url."git@github.com:".insteadOf "https://github.com/"
    

2. 手动克隆依赖到本地再引入

若网络稳定性极差,手动下载Firebase依赖到本地,让CocoaPods从本地读取:

  • 克隆指定版本的Firebase iOS SDK到本地:git clone --branch 11.2.0 https://github.com/firebase/firebase-ios-sdk.git
  • 修改项目Podfile,指定Firebase组件的本地路径:
    pod 'Firebase/Core', :path => '/本地存储路径/firebase-ios-sdk/CoreOnly'
    # 其他组件如Auth、Firestore等,对应到本地SDK的子文件夹路径
    
  • 执行pod install,此时CocoaPods将直接使用本地文件,无需远程克隆

3. 调整Git超时与传输配置

除增大http.postBuffer外,补充以下配置提升网络容错性:

git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999
git config --global core.compression 0

4. 分批次安装Firebase组件

避免一次性拉取所有组件,减少单次克隆的数据量:

  • 先修改Podfile仅保留核心组件:pod 'Firebase/CoreOnly'
  • 执行pod install确认成功后,再逐个添加pod 'Firebase/Auth'等其他组件,每次添加后执行pod install

5. 替换CocoaPods源为镜像

若所在地区有可靠的CocoaPods镜像,替换默认源:

  • 移除默认源:pod repo remove trunk
  • 添加镜像源(如清华镜像):pod repo add trunk https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git
  • 执行pod install --verbose验证拉取情况

内容的提问来源于stack exchange,提问作者rovshenhojayev

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.17 00:44:50