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

Flutter iOS构建失败:CocoaPods无法找到兼容的Firebase/Auth版本

解决Flutter项目iOS构建时Firebase SDK版本冲突问题

问题分析

你的问题是本地Pod缓存和Podfile.lock文件残留了旧版本Firebase SDK(9.6.0)的记录,而当前Flutter Firebase插件依赖的是10.0.0版本,导致版本不兼容,并非官方SDK的bug。

解决步骤

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

  • 进入项目的iOS目录:
    cd ios
    
  • 删除旧的Podfile.lock和Pods文件夹:
    rm Podfile.lock
    rm -rf Pods
    
  • 回到项目根目录,清理Flutter缓存:
    cd ..
    flutter clean
    

2. 统一Firebase SDK版本(可选)

在ios/Podfile中添加版本指定代码,确保所有插件依赖同一版本的Firebase SDK:

platform :ios, '12.0' # Firebase 10+要求最低iOS版本为12.0,可根据你的项目调整

# 新增该行,锁定Firebase SDK版本
$FirebaseSDKVersion = '10.0.0'

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

3. 重新安装Pods

  • 更新Pod仓库并安装依赖:
    cd ios
    pod install --repo-update
    

4. 验证构建

回到项目根目录,重新运行项目:

cd ..
flutter run

补充说明

你不需要回退firebase_auth版本,当前使用的firebase_core:^2.1.1、firebase_storage:^11.0.4、firebase_auth:^4.1.1、cloud_firestore:^4.0.4版本都是兼容Firebase SDK 10.x的,问题根源是本地残留的旧依赖记录。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 01:05:18