Flutter iOS项目更新后CocoaPods依赖冲突问题求助
Flutter iOS端依赖树损坏问题解决指南
问题复现
最近更新Flutter项目后,iOS端依赖树完全损坏,报错流程如下:
- 初始报错:
Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies. To update the CocoaPods specs, run: pod repo update
- 执行
pod repo update后运行pod install,触发GoogleSignIn版本兼容错误:
[!] CocoaPods could not find compatible versions for pod "GoogleSignIn": In snapshot (Podfile.lock): GoogleSignIn (= 7.0.0, ~> 7.0) In Podfile: google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`) was resolved to 0.0.1, which depends on GoogleSignIn (~> 7.1) [!] CocoaPods could not find compatible versions for pod "GoogleSignIn": In snapshot (Podfile.lock): GoogleSignIn (= 7.0.0, = 7.1) In Podfile: google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`) was resolved to 0.0.1, which depends on GoogleSignIn (~> 7.1) You have either: * changed the constraints of dependency `GoogleSignIn` inside your development pod `google_sign_in_ios`. You should run `pod update GoogleSignIn` to apply changes you've made.
- 执行
pod update GoogleSignIn后,要么重复报错,要么引发其他Pod的兼容问题。
项目pubspec.yaml配置如下:
# Prevent accidental publishing to pub.dev. publish_to: 'none' version: 1.0.0+1 environment: sdk: '>=3.1.1 <4.0.0' dependencies: auth_repository: path: packages/auth_repository form_inputs: path: packages/form_inputs equatable: ^2.0.5 flutter: sdk: flutter flutter_localizations: sdk: flutter cached_network_image: ^3.2.3 qr_flutter: ^4.1.0 firebase_core: ^2.15.1 mobile_scanner: ^3.5.5 flutter_riverpod: ^2.4.9 # Use the latest version firebase_auth: ^4.17.8 google_sign_in: ^6.2.1 sign_in_with_apple: ^5.0.0 image_picker: ^1.0.8 firebase_messaging: ^14.7.19 cloud_firestore: ^4.15.8 json_annotation: ^4.8.1 flutter_dotenv: ^5.1.0 datetime_picker_formfield: ^2.0.1 bloc: ^8.1.4 flutter_bloc: ^8.1.5 flow_builder: ^0.1.0 formz: ^0.6.1 font_awesome_flutter: ^10.7.0 easy_search_bar: ^2.5.0 date_picker_plus: ^4.0.0 flutter_typeahead: ^5.2.0 multi_select_flutter: ^4.1.3 bloc_test: ^9.1.7 intl: 0.19.0 http: ^1.2.0 mockito: ^5.4.4 objectid: ^3.0.0 url_launcher: ^6.3.0 dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 test: ^1.24.9 build_runner: ^2.4.12 flutter: uses-material-design: true # Enable generation of localized Strings from arb files. generate: true assets: # Add assets from the images directory to the application. - assets/images/ - .env
解决方案
1. 彻底清理CocoaPods相关文件与缓存
- 进入项目iOS目录:
cd ios - 删除锁文件:
rm Podfile.lock - 删除Pods文件夹:
rm -rf Pods - 清理CocoaPods全局缓存:
pod cache clean --all - 更新spec仓库:
pod repo update
2. 全量更新依赖并重新安装
- 执行全量更新:
pod update(避免单独更新单个Pod导致局部依赖冲突) - 完成后执行安装:
pod install
3. 同步Flutter依赖
- 返回项目根目录,清理Flutter缓存:
flutter clean - 重新获取Flutter依赖:
flutter pub get - 再次进入iOS目录执行
pod install
4. 版本兼容性检查
- 当前
google_sign_in: ^6.2.1对应的iOS插件依赖GoogleSignIn ~>7.1,而旧锁文件锁定的是7.0.0,这是冲突核心。优先通过全量更新解决,若仍有问题,可尝试升级google_sign_in到最新稳定版,或暂时锁定兼容版本。 - 确保所有Firebase插件版本保持一致(当前配置中的firebase_core、firebase_auth等版本匹配,无需调整)
额外建议
- 更新CocoaPods到最新版本:
sudo gem install cocoapods
内容的提问来源于stack exchange,提问作者patrick menendez
相关产品推荐
相关产品推荐

