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

添加firebase_auth到Flutter应用后出现CocoaPods版本兼容错误

解决Flutter中firebase_auth与mobile_scanner的GTMSessionFetcher版本冲突问题

这个问题核心是两个插件依赖了GTMSessionFetcher/Core的不同版本:

  • firebase_auth 4.0.2 要求版本 ~>2.1
  • 旧版mobile_scanner(0.0.1)依赖的GoogleMLKit组件要求版本 ~>1.1

以下是可行的解决方法:

方法1:升级mobile_scanner到最新版本

你的mobile_scanner版本是0.0.1,属于非常早期的版本,后续版本大概率已经更新了依赖的MLKit组件,兼容更高版本的GTMSessionFetcher。

  • 修改pubspec.yaml中的mobile_scanner版本为最新稳定版(比如目前的5.0.0+):
    dependencies:
      mobile_scanner: ^5.0.0
    
  • 执行命令更新依赖:
    flutter pub get
    cd ios
    arch -x86_64 pod install # Intel芯片直接用 pod install
    

方法2:强制指定GTMSessionFetcher版本(临时方案)

如果暂时无法升级mobile_scanner,可以在iOS的Podfile中强制锁定GTMSessionFetcher的版本,适配firebase_auth的要求:

  1. 打开ios/Podfile,在target 'Runner' do代码块内添加:
    pod 'GTMSessionFetcher/Core', '~> 2.1'
    
  2. 清理旧缓存并重新安装Pods:
    flutter clean
    rm -rf ios/Pods ios/Podfile.lock
    flutter pub get
    cd ios
    arch -x86_64 pod install
    

⚠️ 注意:强制版本可能导致mobile_scanner出现运行时兼容性问题,仅作为临时过渡方案,优先推荐方法1。

方法3:清理CocoaPods缓存

如果上述方法无效,尝试清理CocoaPods全局缓存:

pod cache clean --all
# 再执行方法1或2的步骤

内容的提问来源于stack exchange,提问作者نعمان منذر محمود الجميلي

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 08:10:31