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

Flutter iOS构建报错:CocoaPods无法找到兼容的Firebase版本

解决Flutter Firebase iOS构建版本冲突问题

核心问题

本地Podfile.lock中锁定的Firebase核心版本(9.3.0)与Flutter插件firebase_auth依赖的Firebase版本(8.14.0)不匹配,导致CocoaPods无法找到兼容版本,且其他Firebase包存在同类版本冲突。

解决步骤

1. 清理CocoaPods本地缓存与锁定文件

  • 进入项目的iOS目录:
    cd ios
    
  • 删除版本锁定文件:
    rm Podfile.lock
    
  • 删除已安装的Pods文件夹:
    rm -rf Pods
    
  • 清空CocoaPods本地缓存:
    pod cache clean --all
    

2. 统一Flutter Firebase插件版本

打开项目根目录的pubspec.yaml,将所有Firebase相关插件更新到相互兼容的版本(建议使用官方同步更新的版本组,避免跨版本依赖冲突)。示例配置:

dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^2.15.0
  firebase_auth: ^4.10.0
  cloud_firestore: ^4.8.0

执行插件更新命令:

flutter pub get

3. 重新安装CocoaPods依赖

回到iOS目录,执行安装命令:

pod install

若遇到仓库同步问题,强制更新CocoaPods仓库后再安装:

pod install --repo-update

4. 额外排查(若上述步骤无效)

  • 检查ios/Podfile是否手动指定了Firebase版本,若有则删除该配置,让插件自动管理依赖。
  • 更新Xcode命令行工具:
    xcode-select --install
    
  • 清理Xcode构建缓存:打开Xcode,点击Product > Clean Build Folder,之后重启项目重新构建。

原始报错信息:
[!] CocoaPods could not find compatible versions for pod "Firebase/Auth":
In snapshot (Podfile.lock):
Firebase/Auth (= 9.3.0)

In Podfile:
   firebase_auth (from `.symlinks/plugins/firebase_auth/ios`) was resolved to 3.3.12, which depends on Firebase/Auth (= 8.14.0)

内容的提问来源于stack exchange,提问作者Moaz El-sawaf

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 19:15:11