Flutter iOS项目中GTMSessionFetcher/Core与Firebase Auth、Google ML Kit版本冲突问题
解决Flutter项目中Firebase Auth与Google ML Kit的GTMSessionFetcher版本冲突问题
你的问题核心是Firebase Auth与Google ML Kit依赖的GTMSessionFetcher/Core版本范围不兼容:Firebase Auth要求版本≥2.1,而Google ML Kit依赖的版本是~>1.1,导致CocoaPods无法找到兼容版本。以下是几种可行的解决方法:
方法一:降级Firebase Auth到兼容版本
找到同时适配两个库的Firebase Auth版本,比如firebase_auth: ^4.1.0(对应Firebase 9.6.0),该版本依赖的GTMSessionFetcher/Core范围是~>1.1,和Google ML Kit的依赖要求一致。
- 修改
pubspec.yaml中的firebase_auth版本:dependencies: firebase_auth: ^4.1.0 # 其他依赖保持不变 - 执行
flutter pub get更新依赖 - 进入iOS目录清理缓存并重新安装Pods:
cd ios rm Podfile.lock rm -rf Pods pod install
方法二:强制指定GTMSessionFetcher版本(应急方案)
通过CocoaPods强制锁定GTMSessionFetcher/Core到双方都兼容的版本(比如1.7.2),但这种方式可能带来潜在兼容性风险,需充分测试功能。
- 打开iOS目录下的
Podfile,在你的target块中添加:target 'Runner' do use_frameworks! use_modular_headers! flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) # 添加强制指定版本 pod 'GTMSessionFetcher/Core', '~> 1.7.2' end - 执行更新命令:
cd ios pod install --repo-update
方法三:等待Google ML Kit更新依赖
目前google_ml_kit_commons的版本(0.2.0)依赖的MLKitVision版本较低,导致对GTMSessionFetcher的版本要求偏旧。可以关注google_ml_kit_commons的版本更新,待其升级支持更高版本的GTMSessionFetcher后,再将两个库升级到最新版。
内容的提问来源于stack exchange,提问作者Waqas Farooq
相关产品推荐
相关产品推荐

