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

已提交pubspec.lock与Podfile.lock,Flutter仍升级包致iOS依赖冲突

解决Firebase/Performance版本冲突且保持依赖版本一致的方案

问题场景

已提交pubspec.lock和Podfile.lock到Git,但克隆项目后在iOS目录执行pod install时出现版本冲突:

[!] CocoaPods could not find compatible versions for pod "Firebase/Performance":
  In snapshot (Podfile.lock):
    Firebase/Performance (= 10.7.0)

  In Podfile:
    firebase_performance (from `.symlinks/plugins/firebase_performance/ios`) was resolved to 0.9.2-1, which depends on
      Firebase/Performance (= 10.9.0)


You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `Firebase/Performance` inside your development pod `firebase_performance`.
   You should run `pod update Firebase/Performance` to apply changes you've made.

核心矛盾:Podfile.lock锁定Firebase/Performance为10.7.0,但pubspec.lock中firebase_performance 0.9.2+1依赖10.9.0版本,且无法执行pod repo update以保证CI/CD依赖完全匹配本地版本。

解决方案

方法1:对齐插件版本与Pod锁定版本

  1. 修改项目根目录的pubspec.yaml,将firebase_performance的依赖从^0.9.0+16改为具体版本,选择依赖Firebase/Performance 10.7.0的插件版本(例如0.9.0+16,可通过插件发布日志确认对应版本关系):
    dependencies:
      firebase_performance: 0.9.0+16
    
  2. 执行flutter pub get更新pubspec.lock,确保插件版本锁定为指定版本。
  3. 进入iOS目录,执行pod install --no-repo-update,使用本地缓存的依赖完成安装,此时Podfile.lock的版本会与插件依赖完全匹配。
  4. 将更新后的pubspec.lock和Podfile.lock重新提交到Git,后续克隆项目执行pod install --no-repo-update即可正常完成依赖安装。

方法2:更新Pod锁定版本以匹配插件(需本地缓存对应版本)

如果需要保留firebase_performance 0.9.2+1:

  1. 确保本地CocoaPods缓存中已存在Firebase/Performance 10.9.0版本(可从本地其他项目缓存复制,或提前在允许更新的环境下载后迁移缓存)。
  2. 进入iOS目录,执行pod update Firebase/Performance --no-repo-update,仅更新该Pod版本而不刷新仓库源。
  3. 将更新后的Podfile.lock提交到Git,确保CI/CD环境的CocoaPods缓存包含该版本,即可正常执行pod install --no-repo-update。

关键注意事项

  • 必须保证pubspec.lock和Podfile.lock的依赖版本完全兼容后再提交,避免出现克隆后的版本冲突。
  • CI/CD环境需同步本地的CocoaPods缓存,或提前在CI环境中预存所需版本的Pod包,确保--no-repo-update能正常拉取依赖。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 15:32:49