Xcode12,框架构建失败,cocoapods,arm64

Xcode 12, framework build failed, cocoapods, arm64

我尝试使用 cocoapods-packager:

从 podspec 生成一个框架
pod package MyCore.podspec --embedded --subspecs=SDK

在 Xcode 11 中,一切正常,但在 Xcode 12 中,出现以下错误:

fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: Pods/build/package.a and Pods/build-sim/package.a have the same architectures (arm64) and can't be in the same fat output file

这里建议的解决方案: 补充:

s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }

对我不起作用。这与我使用依赖项的事实有关吗?有人知道如何解决这个问题吗?

Podspec: 
#
# Be sure to run `pod lib lint **.podspec' to ensure this is a
# valid spec and remove all comments before submitting the spec.
#
# Any lines starting with a # are optional, but encouraged
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name            = "MyCore"
  s.version         = "9.1.1.2360"
  s.summary         = "A short description of ***."
  s.homepage        = "https://github.com/***/***"
  s.license         = 'Private'
  s.author          = { "***" }
  s.source          = { :git => "***", :tag => s.version.to_s }
  
  s.platform        = :ios, '10.0'
  s.requires_arc    = true
  
  s.module_name     = '***'
  s.default_subspec = 'Core'
  s.static_framework = true
  s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }
  s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }

  s.subspec 'Core' do |ss|
      ss.source_files = 'Pod/Classes/**/*.{h,m,c}'
      ss.resources =     ['Pod/CoreData/DrivePal.{xcdatamodeld,xcmappingmodel}', 'Pod/CoreData/mapping_*.xcmappingmodel', 'Pod/Assets/**/*.{csv,storyboard}']
      ss.resource_bundle = { 
        '**Core_CoreData' => ['Pod/CoreData/DrivePal.{xcdatamodeld,xcmappingmodel}', 'Pod/CoreData/mapping_*.xcmappingmodel','Pod/Assets/**/crash*.txt'],
      }
      ss.preserve_paths = ['Pod/CoreData/*.xcdatamodeld', 'Pod/CoreData/*.xcmappingmodel']
      ss.frameworks = 'CoreLocation', 'CoreBluetooth', 'CoreMotion', 'CoreData', 'AVFoundation', 'SystemConfiguration', 'Foundation'
      ss.library = 'z'

      ss.dependency 'CocoaLumberjack', '~> 3.5.3'
      ss.dependency 'Mantle', '2.1.4'
      ss.dependency 'MTLManagedObjectAdapter', '~> 1.0.3'

      ss.dependency 'AFNetworking/Serialization', '~> 3.2.1'
      ss.dependency 'AFNetworking/Reachability', '~> 3.2.1'
      ss.dependency 'AFNetworking/NSURLSession', '~> 3.2.1'

      ss.test_spec '***CoreTests' do |core_tests|
        core_tests.source_files = 'Pod/***CoreTests/**/*.{h,m}'
        core_tests.resources = 'Pod/***CoreTests/**/*.{json,txt}'
      end
  end
  
  # Core is copy of SDK
  s.subspec 'SDK' do |sdk|
      sdk.source_files = 'Pod/Classes/**/*.{h,m,c}'
      sdk.exclude_files = ['Pod/***CoreTests/*']
      sdk.resources =     ['Pod/CoreData/DrivePal.{xcdatamodeld,xcmappingmodel}', 'Pod/CoreData/mapping_*.xcmappingmodel']
      sdk.resource_bundle = {
          '***Core_CoreData' => ['Pod/CoreData/DrivePal.{xcdatamodeld,xcmappingmodel}','Pod/CoreData/mapping_*.xcmappingmodel','Pod/Assets/**/crash*.txt'],
      }
      sdk.compiler_flags = '-DTESTING=0'
      sdk.preserve_paths = ['Pod/CoreData/*.xcdatamodeld', 'Pod/CoreData/*.xcmappingmodel']
      sdk.frameworks = 'CoreLocation', 'CoreBluetooth', 'CoreMotion', 'CoreData', 'AVFoundation', 'SystemConfiguration', 'Foundation'
      sdk.library = 'z'
      
      sdk.dependency 'CocoaLumberjack', '~> 3.5.3'
      sdk.dependency 'Mantle', '2.1.4'
      sdk.dependency 'MTLManagedObjectAdapter', '~> 1.0.3'

      sdk.dependency 'AFNetworking/Serialization', '~> 3.2.1'
      sdk.dependency 'AFNetworking/Reachability', '~> 3.2.1'
      sdk.dependency 'AFNetworking/NSURLSession', '~> 3.2.1'

      sdk.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64', 'ONLY_ACTIVE_ARCH' => 'YES' }
      sdk.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64','ONLY_ACTIVE_ARCH' => 'YES' }

      sdk.public_header_files = [****]
    end

end

更新: 如果我添加 --exclude-deps 标志,它可以工作,但我的框架不包含依赖项。

通过修改本地cocoapods-packager源ruby代码解决。 修改后的 .rb 文件路径:

/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/pod_utils.rb (path may be different /Users/USER/.rvm/gems/ruby-2.6.3/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/pod_utils.rb)

unless static_installer.nil?
  static_installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO'
      config.build_settings['GCC_GENERATE_DEBUGGING_SYMBOLS'] = 'NO'
      config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' // <-- inserted here
    end
  end
  static_installer.pods_project.save
end