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

Flutter iOS构建pod install失败求助:Firebase版本冲突

解决Flutter iOS端Pod Install版本兼容问题的详细步骤

步骤1:彻底清理项目缓存与Pod相关文件

  • 在Flutter项目根目录执行:
    flutter clean
    flutter pub get
    
  • 进入iOS子目录:
    cd ios
    
  • 删除旧的Pod锁定文件和Pods文件夹:
    rm Podfile.lock
    rm -rf Pods
    
  • 删除Xcode的DerivedData缓存(避免旧缓存干扰):
    rm -rf ~/Library/Developer/Xcode/DerivedData
    

步骤2:更新CocoaPods到兼容版本

旧版本CocoaPods可能无法解析新版Firebase的依赖,先检查当前版本:

pod --version

如果版本低于1.12.0,执行更新:

sudo gem install cocoapods

步骤3:强制更新Firebase/Firestore依赖

在iOS目录下执行,直接更新Firebase/Firestore到符合cloud_firestore要求的版本:

pod update Firebase/Firestore

如果需要更新所有Firebase组件,也可以执行:

pod update Firebase

步骤4:检查并同步Firebase插件版本(关键)

打开项目根目录的pubspec.yaml,确保所有Firebase相关插件(如firebase_core、cloud_firestore)版本兼容:

  • cloud_firestore 4.8.1需要搭配firebase_core >=2.15.0(可在pub.dev查看插件的依赖说明)
  • 如果版本不匹配,修改pubspec.yaml中的版本号,然后执行:
    flutter pub get
    
    再回到iOS目录重新执行pod install

步骤5:排查Podfile中的固定版本配置

打开iOS目录下的Podfile,检查是否有手动固定Firebase版本的代码(类似pod 'Firebase/Firestore', '10.3.0'):

  • 如果有,删除该行或修改为兼容的版本(如10.10.0及以上)
  • 保存后重新执行pod install

步骤6:查看详细错误日志(若仍失败)

执行pod install时加上--verbose参数,查看完整错误信息,定位具体冲突点:

pod install --verbose

内容的提问来源于stack exchange,提问作者HY-Yap

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 06:52:15