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

iOS模拟器编译报错:IPHONEOS_DEPLOYMENT_TARGET版本不兼容

编译iOS项目时IPHONEOS_DEPLOYMENT_TARGET版本不兼容问题

问题详情

编译iOS模拟器/设备项目时触发报错:

The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.2.99. (in target 'DKPhotoGallery' from project 'Pods')

已执行的排查操作:

  • 取消注释Podfile中的platform :ios, '11.0'
  • 在Podfile中添加post_install钩子统一设置所有Pod部署目标为iOS 11:
post_install do |installer|
 installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
   config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
  end
 end
end
  • 每次操作前清理项目缓存、删除Podfile.lock文件并重新执行pod install

设备为MacBook Air M1,此前项目可正常编译,问题近期突然出现,重新克隆项目后依旧存在。

解决方案

1. 指定DKPhotoGallery适配版本

部分旧版本DKPhotoGallery未适配高版本Xcode的最低部署要求,在Podfile中明确指定适配iOS11+的版本:

pod 'DKPhotoGallery', '~> 0.0.24' # 替换为实际兼容的稳定版本

2. 优化post_install钩子(针对特定Pod)

原钩子可能未覆盖DKPhotoGallery的全部配置,修改钩子单独处理该Pod:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'DKPhotoGallery'
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
        # 若仍有SDK版本相关报错,可添加以下配置(替换为你的Xcode对应SDK版本)
        # config.build_settings['SDKROOT'] = 'iphoneos16.2'
      end
    end
  end
end

3. 彻底清理缓存

执行以下命令清除深层缓存后重新安装Pods:

rm -rf ~/Library/Caches/CocoaPods
rm -rf Pods
rm Podfile.lock
pod deintegrate
pod setup
pod install

4. 检查主项目部署目标

打开项目Build Settings,确认主项目的IPHONEOS_DEPLOYMENT_TARGET设置为11.0及以上,避免与Pod的部署目标冲突。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 02:25:24