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

Pod Spec Lint报错:依赖部署目标低于Xcode最低要求的解决咨询

问题描述

执行pod spec lint时触发报错:

  • ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.

经排查确定是依赖的最低iOS部署版本不匹配,相关提示信息如下:

  • NOTE | [iOS] xcodebuild: Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 17.4.99. (in target 'CGRPCZlib' from project 'Pods')

当前使用Xcode 15.3(最低支持iOS 12.0),私有Pod的.podspec内容如下:

Pod::Spec.new do |spec|

  spec.name         = "app-service-ios"
  spec.version      = "0.0.2"
  spec.summary      = "###summary"
  spec.homepage     = "###homepage url"
  spec.author       = { "###email" }
  spec.source       = { :git => "###git link", :tag => spec.version.to_s }
  spec.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
  spec.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
  spec.ios.deployment_target = '12.0'
  spec.swift_version = '5.0'
  spec.source_files  = 'Classes/*.grpc.swift'

  spec.dependency 'SwiftProtobuf', '1.26.0'
  spec.dependency 'gRPC-Swift'

end

已知pod install场景下可通过post_install修改依赖的部署版本,询问如何在.podspec文件中处理该问题。

解决方案

1. 锁定依赖的兼容版本

检查gRPC-Swift的版本兼容性,指定一个明确支持iOS 12.0的版本范围,避免拉取包含低部署目标子依赖(如CGRPCZlib)的旧版依赖:

spec.dependency 'gRPC-Swift', '~> 1.20.0' # 确认该版本支持iOS 12.0后使用

2. 通过pod_target_xcconfig强制覆盖部署目标

在.podspec的pod_target_xcconfig中添加IPHONEOS_DEPLOYMENT_TARGET配置,强制当前Pod的所有依赖使用指定的部署目标:

spec.pod_target_xcconfig = { 
  'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64',
  'IPHONEOS_DEPLOYMENT_TARGET' => '12.0'
}

3. 结合post_install在lint阶段临时生效

若上述方法无效,可创建一个临时配置文件在lint时应用post_install逻辑:

  1. 创建lint_config.rb文件:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end
  1. 执行lint命令时指定该配置文件:
pod spec lint --config=lint_config.rb

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 19:47:19