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

运行pod install时遭遇PhoneNumberKit/PhoneNumberKitCore版本兼容错误求助

解决PhoneNumberKit版本冲突导致的pod install失败问题

问题详情

运行pod install时出现如下版本冲突错误:

[!] CocoaPods could not find compatible versions for pod "PhoneNumberKit/PhoneNumberKitCore":
  In Podfile:
    PhoneNumberKit (from `https://github.com/marmelroy/PhoneNumberKit`) was resolved to 3.6.5, which depends on
      PhoneNumberKit/PhoneNumberKitCore (= 3.6.5)
    flutter_libphonenumber_ios (from `.symlinks/plugins/flutter_libphonenumber_ios/ios`) was resolved to 1.1.0, which depends on
      PhoneNumberKit/PhoneNumberKitCore (= 3.6.0)
Specs satisfying the `PhoneNumberKit/PhoneNumberKitCore (= 3.6.0), PhoneNumberKit/PhoneNumberKitCore (= 3.6.5)` dependency were found, but they required a higher minimum deployment target.

已尝试提升最低部署目标至12.0、删除Podfile.lock、执行pod repo update、flutter clean等操作,均未解决问题,当前使用flutter_libphonenumber: 2.1.4。

解决方案

1. 强制统一PhoneNumberKitCore版本

在iOS项目目录的Podfile中,明确指定PhoneNumberKit/PhoneNumberKitCore的版本,覆盖插件的依赖要求:

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  
  # 强制使用兼容版本(这里选择3.6.5,需确保项目支持其部署要求)
  pod 'PhoneNumberKit/PhoneNumberKitCore', '3.6.5'
end

2. 彻底清理并重新安装依赖

执行以下命令完成清理与重装:

flutter clean
cd ios
rm Podfile.lock
pod repo update
pod install --repo-update
cd ..
flutter pub get

3. 调整最低部署目标

若仍提示部署目标不足,将iOS项目的最低部署目标提升至13.0(PhoneNumberKit 3.6.5的最低要求):

  • 打开iOS项目的Runner.xcworkspace
  • 在项目设置的Deployment Info中,将Minimum Deployments设为13.0
  • 保存后重新执行pod install

4. 匹配依赖版本(备选方案)

如果强制统一高版本无效,可临时降级PhoneNumberKit至插件要求的3.6.0版本:

# 在Podfile中替换为指定版本
pod 'PhoneNumberKit', '3.6.0'

原因说明

冲突核心是两个依赖对PhoneNumberKit/PhoneNumberKitCore的版本要求不一致:项目直接依赖的PhoneNumberKit为3.6.5,而flutter_libphonenumber_ios插件依赖3.6.0。即使提升部署目标,CocoaPods也无法同时满足两个不同的版本约束,因此需要通过强制统一版本或调整依赖来解决。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 07:52:47