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

Flutter项目执行pod install时持续出现依赖版本兼容错误

M1 MacBook执行pod install时的CocoaPods依赖兼容错误解决

在M1芯片的MacBook上执行pod install时,CocoaPods持续返回依赖版本兼容错误,具体报错信息如下:

milosn@MacBookPro ios % pod install
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '10.25.0' defined in 'firebase_core'
cloud_functions: Using Firebase SDK version '10.25.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '10.25.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '10.25.0' defined in 'firebase_core'
Run script to upload symbols already exists.
firebase_crashlytics: Using Firebase SDK version '10.25.0' defined in 'firebase_core'
firebase_messaging: Using Firebase SDK version '10.25.0' defined in 'firebase_core'
firebase_performance: Using Firebase SDK version '10.25.0' defined in 'firebase_core'
firebase_storage: Using Firebase SDK version '10.25.0' defined in 'firebase_core'
[!] CocoaPods 无法找到兼容版本的 pod "GTMSessionFetcher/Core":
  In Podfile:
    cloud_functions (from `.symlinks/plugins/cloud_functions/ios`) 已解析为 4.7.6,依赖于
      Firebase/Functions (= 10.25.0) 已解析为 10.25.0,依赖于
        FirebaseFunctions (~> 10.25.0) 已解析为 10.25.0,依赖于
          GTMSessionFetcher/Core (< 4.0, >= 2.1)

    google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`) 已解析为 0.0.1,依赖于
      GoogleSignIn (~> 7.1) 已解析为 7.1.0,依赖于
        GTMAppAuth (< 5.0, >= 4.1.1) 已解析为 4.1.1,依赖于
          GTMSessionFetcher/Core (< 4.0, >= 3.3)

    google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`) 已解析为 0.0.1,依赖于
      GoogleSignIn (~> 7.1) 已解析为 7.1.0,依赖于
        GTMSessionFetcher/Core (~> 3.3)

    mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`) 已解析为 3.5.6,依赖于
      GoogleMLKit/BarcodeScanning (~> 4.0.0) 已解析为 4.0.0,依赖于
        MLKitBarcodeScanning (~> 3.0.0) 已解析为 3.0.0,依赖于
          MLKitVision (~> 5.0) 已解析为 5.0.0,依赖于
            GTMSessionFetcher/Core (< 3.0, >= 1.1)

CocoaPods 无法找到兼容版本的 pod "GoogleUtilities/Logger":
  In Podfile:
    firebase_core (from `.symlinks/plugins/firebase_core/ios`) 已解析为 2.32.0,依赖于
      Firebase/CoreOnly (= 10.25.0) 已解析为 10.25.0,依赖于
        FirebaseCore (= 10.25.0) 已解析为 10.25.0,依赖于
          GoogleUtilities/Logger (~> 7.12)

    firebase_performance (from `.symlinks/plugins/firebase_performance/ios`) 已解析为 0.9.4-7,依赖于
      Firebase/Performance (= 10.25.0) 已解析为 10.25.0,依赖于
        FirebasePerformance (~> 10.25.0) 已解析为 10.25.0,依赖于
          GoogleUtilities/MethodSwizzler (~> 7.13) 已解析为 7.13.3,依赖于
            GoogleUtilities/Logger (= 7.13.3)

    mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`) 已解析为 3.5.6,依赖于
      GoogleMLKit/BarcodeScanning (~> 4.0.0) 已解析为 4.0.0,依赖于
        MLKitBarcodeScanning (~> 3.0.0) 已解析为 3.0.0,依赖于
          MLKitCommon (~> 9.0) 已解析为 9.0.0,依赖于
            GoogleUtilitiesComponents (~> 1.0) 已解析为 1.1.0,依赖于
              GoogleUtilities/Logger

环境信息

  • Flutter版本:3.29.0(stable通道),Dart 3.7.0
  • CocoaPods版本:1.16.2
  • 设备:MacBook M1
  • Flutter项目依赖配置(pubspec.yaml):
environment:
  sdk: ">=2.16.1 <3.0.0"

dependencies:
  add_2_calendar: ^3.0.1
  animate_do: ^4.2.0
  app_links: ^4.0.1
  auto_route: ^5.0.1
  before_after: ^3.1.0
  bloc: ^8.1.0
  cached_network_image: ^3.2.1
  carousel_slider: ^5.0.0
  cloud_firestore: ^4.15.9
  cloud_functions: ^4.6.9
  collection: ^1.16.0
  cupertino_icons: ^1.0.2
  dartz: ^0.10.1
  dotted_border: ^2.0.0+2
  easy_localization: ^3.0.0
  enum_to_string: ^2.0.1
  equatable: ^2.0.5
  firebase_auth: ^4.17.9
  firebase_core: ^2.27.1
  firebase_crashlytics: ^3.4.19
  firebase_messaging: ^14.7.20
  firebase_performance: ^0.9.3+18
  firebase_storage: ^11.6.10
  flutter:
    sdk: flutter
  flutter_bloc: ^8.1.0
  flutter_datetime_picker_plus: ^2.2.0
  flutter_local_notifications: ^18.0.1
  flutter_map: ^4.0.0
  flutter_markdown: ^0.7.6+2
  flutter_native_splash: ^2.0.5
  form_validator: ^2.1.1
  geocoding: ^3.0.0
  geolocator: ^9.0.1
  get_it: ^7.2.0
  google_sign_in: ^5.2.4
  google_sign_in_ios: ^5.7.5
  http: ^0.13.6
  hydrated_bloc: ^9.0.0
  image_cropper:
    path: ./lib/core/packages/image_cropper/image_cropper
  image_cropper_for_web:
    path: ./lib/core/packages/image_cropper/image_cropper_for_web
  image_cropper_platform_interface:
    path: ./lib/core/packages/image_cropper/image_cropper_platform_interface
  image_gallery_saver: ^2.0.3
  image_picker: ^1.1.2
  internet_connection_checker: ^1.0.0+1
  intl: ^0.17.0
  introduction_screen: ^3.1.14
  json_annotation: ^4.4.0
  latlong2: ^0.8.1
  mobile_scanner: ^4.0.0
  path_provider: ^2.0.9
  permission_handler: ^11.4.0
  photo_view:
    git:
      url: https://github.com/bluefireteam/photo_view
      ref: main
  rxdart: ^0.27.3
  share_plus: ^10.0.0
  shared_preferences: ^2.0.13
  shimmer: ^3.0.0
  sign_in_with_apple: ^6.1.4
  timeago: ^3.2.2
  url_launcher: ^6.1.2
  uuid: ^4.5.1

dependency_overrides:
  firebase_core_platform_interface: ^5.0.0
  intl: ^0.18.1
  image_cropper_for_web:
    path: ./lib/core/packages/image_cropper/image_cropper_for_web
  image_cropper_platform_interface:
    path: ./lib/core/packages/image_cropper/image_cropper_platform_interface
  url_launcher_ios: ^6.3.1

dev_dependencies:
  auto_route_generator: ^5.0.2
  build_runner:
  flutter_launcher_icons: ^0.14.3
  flutter_lints: ^5.0.0
  flutter_test:
    sdk: flutter
  json_serializable: ^6.1.5
  pedantic_mono: ^1.17.0
  pixel_perfect: ^1.1.1

冲突原因分析

  1. GTMSessionFetcher/Core版本冲突:

    • cloud_functions要求版本范围>=2.1 <4.0
    • google_sign_in_ios要求版本范围>=3.3 <4.0
    • mobile_scanner依赖的Google ML Kit限制版本<3.0
      三者的版本范围无交集,导致CocoaPods无法找到兼容版本。
  2. GoogleUtilities/Logger版本冲突:

    • firebase_core要求~>7.12(即7.12.x)
    • firebase_performance强制要求=7.13.3
    • mobile_scanner间接依赖的版本无明确上限,与前两者版本要求冲突。

解决方案

1. 升级mobile_scanner到兼容高版本依赖的版本

当前配置中mobile_scanner为4.0.0,升级到最新稳定版(如5.0.0及以上),新版本已适配更高版本的Google ML Kit,可兼容>=3.3的GTMSessionFetcher。修改pubspec.yaml:

mobile_scanner: ^5.0.0

2. 强制统一冲突依赖版本(若升级无效)

在pubspec.yaml的dependency_overrides中添加以下配置,强制统一冲突依赖的版本,覆盖所有三方库的依赖要求:

dependency_overrides:
  # 统一GTMSessionFetcher/Core到3.3.0,满足所有依赖的交集要求
  GTMSessionFetcher/Core: 3.3.0
  # 统一GoogleUtilities/Logger到7.13.3,匹配firebase_performance的要求
  GoogleUtilities/Logger: 7.13.3

3. 清理缓存重新执行依赖安装

执行以下命令彻底清理缓存,确保依赖重新解析:

# 清理Flutter项目缓存
flutter clean
flutter pub get

# 进入iOS目录清理CocoaPods缓存
cd ios
pod deintegrate
pod cache clean --all
pod install

4. 统一Firebase依赖版本(可选优化)

将所有Firebase相关依赖升级到最新稳定版,版本一致性可减少潜在的依赖冲突:

cloud_firestore: ^5.0.0
cloud_functions: ^5.0.0
firebase_auth: ^5.0.0
firebase_core: ^3.0.0
firebase_crashlytics: ^4.0.0
firebase_messaging: ^15.0.0
firebase_performance: ^1.0.0
firebase_storage: ^12.0.0

内容的提问来源于stack exchange,提问作者Milos N.

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 23:47:03