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

升级Flutter 3.7后M1 Mac遭遇CocoaPods依赖兼容问题求助

解决Flutter 3.7构建macOS时Firebase CocoaPods依赖冲突问题

以下是针对Firebase/CoreOnly版本冲突问题的可行解决方案:

  • 彻底清理项目缓存与旧依赖
    先清理Flutter项目缓存,再删除iOS和macOS端的CocoaPods相关文件,避免旧依赖残留:

    flutter clean
    rm -rf ios/Pods ios/Podfile.lock macos/Pods macos/Podfile.lock
    rm -rf .flutter-plugins .flutter-plugins-dependencies
    
  • 统一Firebase Flutter包版本
    打开项目根目录的pubspec.yaml,确保所有Firebase相关包版本互相兼容。针对Flutter 3.7,推荐使用适配的稳定版本,例如:

    firebase_core: ^2.15.0
    firebase_auth: ^4.10.0
    

    执行命令更新依赖:

    flutter pub get
    
  • 修复CocoaPods依赖解析(适配Apple Silicon芯片)
    进入macos目录,先更新CocoaPods仓库,再重新安装依赖:

    cd macos
    rm Podfile.lock
    arch -x86_64 pod repo update
    arch -x86_64 pod install --repo-update
    

    如果仍存在版本冲突,修改macos/Podfile,添加post_install钩子强制统一Firebase版本:

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        flutter_additional_ios_build_settings(target)
        target.build_configurations.each do |config|
          # 统一部署目标版本(可根据需求调整)
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
        end
      end
      # 强制锁定Firebase/CoreOnly到满足firebase_auth要求的版本
      installer.pod_targets.each do |target|
        if target.name == 'Firebase/CoreOnly'
          target.version = '9.6.0'
        end
      end
    end
    

    保存后重新执行arch -x86_64 pod install

  • 验证构建
    返回项目根目录,执行构建命令:

    flutter build macos
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 12:55:22