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

Xcode目标iOS14却卡在iOS11编译阶段,求排查解决

解决Xcode强制以iOS11编译,与PhoneNumberKit最低版本冲突的问题

报错信息

Swift Compiler Error (Xcode): Compiling for iOS 11.0, but module 'PhoneNumberKit' has a minimum deployment target of iOS 12.0:
/Users/aris/Library/Developer/Xcode/DerivedData/Runner-cmtnerpxiupormgiakqsqxlnezts/Build/Intermediates.noindex/ArchiveIntermediates/Runner/Build
ProductsPath/Release-iphoneos/PhoneNumberKit/PhoneNumberKit.framework/Modules/PhoneNumberKit.swiftmodule/arm64-apple-ios.swiftmodule
/Users/aris/.pub-cache/hosted/pub.dev/libphonenumber_plugin-0.3.2/ios/Classes/SwiftLibphonenumberPlugin.swift:2:7

已尝试操作

  • 清空Xcode编译文件夹并重新执行pod install
  • 执行pod install --repo-update
  • Podfile首行设置target ios: 14
  • Xcode中Runner目标的Build Settings设置iOS编译目标为14
  • 执行flutter clean; flutter pub get; flutter build ipa
  • 升级Flutter并重新安装所有Pods
  • 删除Xcode的DerivedData文件夹

针对性解决方案

1. 在Podfile中添加统一设置部署目标的脚本

打开ios目录下的Podfile,在文件末尾添加以下脚本,强制所有第三方Pod的部署目标与项目保持一致(iOS14):

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
    end
  end
end

添加后执行cd ios && pod install,该脚本会覆盖所有Pods自身的低版本部署目标设置。

2. 检查并修改Flutter框架的最低版本配置

打开ios/Flutter/AppFrameworkInfo.plist文件,找到MinimumOSVersion字段,确保其值为14.0,若不符则手动修改。

3. 手动修正Pods项目的部署目标(可选)

若上述脚本未生效,可打开Xcode,找到左侧导航栏的Pods项目,逐个检查其中的目标(如PhoneNumberKit),在Build Settings中找到iOS Deployment Target,将其设置为12.0或更高版本(推荐14.0)。注意:此方式会在下次pod install时被重置,优先使用脚本方案。

4. 执行彻底的清理重建流程

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

完成后重新打开Xcode,尝试编译或打包。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.10 11:58:12