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

导入GoogleMLKit/TextRecognition时Pod依赖冲突问题求助

解决MLKit与GTMSessionFetcher版本兼容问题

问题背景

尝试集成MLKit(含Firebase版本)时出现版本冲突错误,已参照官方文档操作,Podfile内容如下:

pod 'MaterialComponents/ActivityIndicator'
pod 'MaterialComponents/Chips'
pod 'Google-Mobile-Ads-SDK'
pod 'IQKeyboardManagerSwift'
pod 'Alamofire'
pod 'SwiftyJSON'
pod "SearchTextField"
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'Firebase/Database'
pod 'Firebase/Analytics'
pod 'Toast-Swift', '~> 5.0.1'
pod 'GoogleMLKit/TextRecognition','2.2.0'

初始错误信息

[!] CocoaPods could not find compatible versions for pod "GTMSessionFetcher/Core":
  In snapshot (Podfile.lock):
    GTMSessionFetcher/Core (< 4.0, = 3.1.0, >= 2.1)

  In Podfile:
    GoogleMLKit/TextRecognition (= 2.2.0) was resolved to 2.2.0, which depends on
      MLKitTextRecognition (~> 1.3.0) was resolved to 1.3.0, which depends on
        MLKitVision (~> 1.3) was resolved to 1.3.0, which depends on
          GTMSessionFetcher/Core (~> 1.1)

Specs satisfying the `GTMSessionFetcher/Core (< 4.0, = 3.1.0, >= 2.1), GTMSessionFetcher/Core (~> 1.1)` dependency were found, but they required a higher minimum deployment target.

尝试官方Issue方案后的新错误

Fetching podspec for `MLKitCommon` from `MLKitCommon.podspec.json`
Fetching podspec for `MLKitVision` from `MLKitVision.podspec.json`
[!] CocoaPods could not find compatible versions for pod "GTMSessionFetcher/Core":
  In snapshot (Podfile.lock):
    GTMSessionFetcher/Core (< 4.0, = 3.1.0, >= 2.1)

  In Podfile:
    MLKitVision (from `MLKitVision.podspec.json`) was resolved to 4.2.0, which depends on
      GTMSessionFetcher/Core (~> 2.1)

Specs satisfying the `GTMSessionFetcher/Core (< 4.0, = 3.1.0, >= 2.1), GTMSessionFetcher/Core (~> 2.1)` dependency were found, but they required a higher minimum deployment target.

解决方案

  • 升级项目最低部署目标:错误核心是依赖需要更高的iOS版本支持,建议将项目的iOS部署目标设置为iOS 12.0及以上(部分新版本组件可能要求iOS 13.0+,可根据实际依赖调整)
  • 彻底清理CocoaPods环境后重装:
    pod deintegrate
    rm Podfile.lock
    pod cache clean --all
    pod install
    
  • 统一MLKit依赖版本:避免混用独立版GoogleMLKit和Firebase集成版MLKit,建议选择其中一套。若使用Firebase生态,替换为Firebase/MLVisionTextRecognition;若用独立版,升级GoogleMLKit/TextRecognition到最新兼容版本
  • 强制锁定GTMSessionFetcher版本:在Podfile中添加明确的版本约束,确保所有依赖适配同一版本,例如:
    pod 'GTMSessionFetcher/Core', '~> 3.1.0'
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 12:22:51