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

pod lib lint校验报错:ViTempSDK-Swift.h等头文件重复

解决pod lib lint校验VitureDeviceSDK时的构建错误

问题重现

执行pod lib lint校验VitureDeviceSDK的podspec时,出现以下构建错误与警告:

/var/folders/bz/s3_w3t2j3l14b7jwfbfc32m40000gp/T/CocoaPods-Lint-20230725-75212-yo2ygu-VitureDeviceSDK/Pods/Pods.xcodeproj: warning: 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.4.99. (in target 'ZIPFoundation' from project 'Pods')
/var/folders/bz/s3_w3t2j3l14b7jwfbfc32m40000gp/T/CocoaPods-Lint-20230725-75212-yo2ygu-VitureDeviceSDK/Pods/Pods.xcodeproj: warning: 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.4.99. (in target 'iOSDFULibrary' from project 'Pods')
warning: duplicate output file '/Users/eduardcalero/Library/Developer/Xcode/DerivedData/App-cyinlyjyloiqciaqiyojesdcymvs/Build/Products/Release-iphonesimulator/VitureDeviceSDK/VitureDeviceSDK.framework/Headers/ViTempSDK-Swift.h' on task: CpHeader /Users/eduardcalero/Library/Developer/Xcode/DerivedData/App-cyinlyjyloiqciaqiyojesdcymvs/Build/Products/Release-iphonesimulator/VitureDeviceSDK/VitureDeviceSDK.framework/Headers/ViTempSDK-Swift.h /Users/eduardcalero/Documents/Repos/VitureSDK_ForIOS/VitureDeviceSDK/VitureDeviceSDK/Frameworks/ViTempSDK.xcframework/ios-arm64_x86_64-simulator/ViTempSDK.framework/Headers/ViTempSDK-Swift.h (in target 'VitureDeviceSDK' from project 'Pods')
warning: duplicate output file '/Users/eduardcalero/Library/Developer/Xcode/DerivedData/App-cyinlyjyloiqciaqiyojesdcymvs/Build/Products/Release-iphonesimulator/VitureDeviceSDK/VitureDeviceSDK.framework/Headers/ViTempSDK.h' on task: CpHeader /Users/eduardcalero/Library/Developer/Xcode/DerivedData/App-cyinlyjyloiqciaqiyojesdcymvs/Build/Products/Release-iphonesimulator/VitureDeviceSDK/VitureDeviceSDK.framework/Headers/ViTempSDK.h /Users/eduardcalero/Documents/Repos/VitureSDK_ForIOS/VitureDeviceSDK/VitureDeviceSDK/Frameworks/ViTempSDK.xcframework/ios-arm64_x86_64-simulator/ViTempSDK.framework/Headers/ViTempSDK.h (in target 'VitureDeviceSDK' from project 'Pods')
** BUILD FAILED **

对应的podspec内容如下:

Pod::Spec.new do |s|
  s.name             = 'VitureDeviceSDK'
  s.version          = '1.0.0'
  s.summary          = 'A short description of VitureDeviceSDK.'

  s.description      = <<-DESC
TODO: Add long description of the pod here.
                       DESC

 s.homepage         = 'https://dev.azure.com/vitio/VitureSDK_ForIOS/_git/VitureSDK_ForIOS?path=/VitureDeviceSDK'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'Eduard Calero' => 'ecalerorovira@outlook.com' }
  s.source           = { :git => 'https://user:***********@dev.azure.com/*****/*****/_git/VitureSDK_ForIOS', :tag => 'VitureDeviceSDK-v1.0.0' }
  s.social_media_url = 'https://twitter.com/EduCalero85'

  s.ios.deployment_target = '15.0'

  s.source_files = 'VitureDeviceSDK/**/*.{h,m,swift,xcframework}'
  s.vendored_frameworks = 'VitureDeviceSDK/Frameworks/ViTempSDK.xcframework'
  s.xcconfig = { 'OTHER_LDFLAGS' => '-framework ViTempSDK' }
  
  s.frameworks = 'UIKit', 'SwiftUI'
  
  s.dependency 'iOSDFULibrary', '~> 4.13.0'
  
  s.public_header_files = 'VitureDeviceSDK/Frameworks/ViTempSDK.xcframework/**/*.h'
end

删除public_header_files配置后,问题依然存在,新的错误日志:

error: Multiple commands produce '/Users/eduardcalero/Library/Developer/Xcode/DerivedData/App-fkjkrcxjdccqtieeghkhmfkomnku/Build/Products/Release-iphonesimulator/VitureDeviceSDK/VitureDeviceSDK.framework/Headers/ViTempSDK-Swift.h'
        note: Target 'VitureDeviceSDK' (project 'Pods') has copy command from '/Users/eduardcalero/Documents/Repos/VitureSDK_ForIOS/VitureDeviceSDK/VitureDeviceSDK/Frameworks/ViTempSDK.xcframework/ios-arm64/ViTempSDK.framework/Headers/ViTempSDK-Swift.h' to '/Users/eduardcalero/Library/Developer/Xcode/DerivedData/App-fkjkrcxjdccqtieeghkhmfkomnku/Build/Products/Release-iphonesimulator/VitureDeviceSDK/VitureDeviceSDK.framework/Headers/ViTempSDK-Swift.h'
        note: Target 'VitureDeviceSDK' (project 'Pods') has copy command from '/Users/eduardcalero/Documents/Repos/VitureSDK_ForIOS/VitureDeviceSDK/VitureDeviceSDK/Frameworks/ViTempSDK.xcframework/ios-arm64_x86_64-simulator/ViTempSDK.framework/Headers/ViTempSDK-Swift.h' to '/Users/eduardcalero/Library/Developer/Xcode/DerivedData/App-fkjkrcxjdccqtieeghkhmfkomnku/Build/Products/Release-iphonesimulator/VitureDeviceSDK/VitureDeviceSDK.framework/Headers/ViTempSDK-Swift.h'
    error: Multiple commands produce '/Users/eduardcalero/Library/Developer/Xcode/DerivedData/App-fkjkrcxjdccqtieeghkhmfkomnku/Build/Products/Release-iphonesimulator/VitureDeviceSDK/VitureDeviceSDK.framework/Headers/ViTempSDK.h'
        note: Target 'VitureDeviceSDK' (project 'Pods') has copy command from '/Users/eduardcalero/Documents/Repos/VitureSDK_ForIOS/VitureDeviceSDK/VitureDeviceSDK/Frameworks/ViTempSDK.xcframework/ios-arm64/ViTempSDK.framework/Headers/ViTempSDK.h' to '/Users/eduardcalero/Library/Developer/Xcode/DerivedData/App-fkjkrcxjdccqtieeghkhmfkomnku/Build/Products/Release-iphonesimulator/VitureDeviceSDK/VitureDeviceSDK.framework/Headers/ViTempSDK.h'
        note: Target 'VitureDeviceSDK' (project 'Pods') has copy command from '/Users/eduardcalero/Documents/Repos/VitureSDK_ForIOS/VitureDeviceSDK/VitureDeviceSDK/Frameworks/ViTempSDK.xcframework/ios-arm64_x86_64-simulator/ViTempSDK.framework/Headers/ViTempSDK.h' to '/Users/eduardcalero/Library/Developer/Xcode/DerivedData/App-fkjkrcxjdccqtieeghkhmfkomnku/Build/Products/Release-iphonesimulator/VitureDeviceSDK/VitureDeviceSDK.framework/Headers/ViTempSDK.h'
    ** BUILD FAILED **

解决方案

1. 修复XCframework重复拷贝问题

问题根源是source_files包含了xcframework后缀,导致CocoaPods同时通过source_files处理XCframework内的所有文件,又通过vendored_frameworks将整个XCframework作为预编译框架引入,两者冲突产生重复的头文件拷贝命令。

修改podspec中的source_files配置,移除xcframework后缀:

s.source_files = 'VitureDeviceSDK/**/*.{h,m,swift}'

2. 消除依赖部署目标警告

iOSDFULibrary和ZIPFoundation的部署目标低于当前SDK要求的11.0,可在podspec中添加post_install钩子,统一修改这些依赖的部署目标:

s.post_install do |installer|
  installer.pods_project.targets.each do |target|
    # 针对指定依赖修改部署目标
    if ['iOSDFULibrary', 'ZIPFoundation'].include?(target.name)
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'
      end
    end
    # 若要统一所有依赖的部署目标,可替换为以下代码:
    # target.build_configurations.each do |config|
    #   config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = s.ios.deployment_target
    # end
  end
end

3. 其他优化建议

  • 移除不必要的xcconfig配置:s.xcconfig = { 'OTHER_LDFLAGS' => '-framework ViTempSDK' },因为vendored_frameworks会自动处理链接,无需手动添加。
  • 确保ViTempSDK.xcframework是完整的多架构XCframework,包含真机和模拟器架构。

修改后的完整podspec示例:

Pod::Spec.new do |s|
  s.name             = 'VitureDeviceSDK'
  s.version          = '1.0.0'
  s.summary          = 'A short description of VitureDeviceSDK.'

  s.description      = <<-DESC
TODO: Add long description of the pod here.
                       DESC

 s.homepage         = 'https://dev.azure.com/vitio/VitureSDK_ForIOS/_git/VitureSDK_ForIOS?path=/VitureDeviceSDK'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'Eduard Calero' => 'ecalerorovira@outlook.com' }
  s.source           = { :git => 'https://user:***********@dev.azure.com/*****/*****/_git/VitureSDK_ForIOS', :tag => 'VitureDeviceSDK-v1.0.0' }
  s.social_media_url = 'https://twitter.com/EduCalero85'

  s.ios.deployment_target = '15.0'

  s.source_files = 'VitureDeviceSDK/**/*.{h,m,swift}'
  s.vendored_frameworks = 'VitureDeviceSDK/Frameworks/ViTempSDK.xcframework'
  
  s.frameworks = 'UIKit', 'SwiftUI'
  
  s.dependency 'iOSDFULibrary', '~> 4.13.0'

  s.post_install do |installer|
    installer.pods_project.targets.each do |target|
      if ['iOSDFULibrary', 'ZIPFoundation'].include?(target.name)
        target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'
        end
      end
    end
  end
end

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 08:10:57