cocoapods-packager icon indicating copy to clipboard operation
cocoapods-packager copied to clipboard

have the same architectures (arm64) and can't be in the same fat output file(Xcode12下编译静态库,包无法合并fat output file)

Open cjlcooper opened this issue 4 years ago • 14 comments

Error Info:have the same architectures (arm64) and can't be in the same fat output file

Xcode Version:12.0.1 cocoapods version: 1.9.3 cocoapods-packager version: 1.5.0

通过pod packager打包静态库,出现模拟器和真机同时包含arm64架构,无法合并为fat file

cjlcooper avatar Sep 30 '20 08:09 cjlcooper

Add line "arm64" (without quotes) to path: Xcode -> Project -> Build settings -> Architectures -> Excluded architectures Also do the same for Pods. In both cases for both debug and release fields. I hope this will help. Best regards.

brave723 avatar Sep 30 '20 09:09 brave723

I tried, but I couldn't solve the problem

tangguoan avatar Oct 03 '20 13:10 tangguoan

The problem is still there. Can anyone help?

Feng999 avatar Oct 13 '20 10:10 Feng999

I found the following solutions,write content in podsepc file: s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }

cjlcooper avatar Oct 14 '20 06:10 cjlcooper

I found the following solutions,write content in podsepc file: s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' } s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64' }

It works, but it's just weird.Also, user_target_xcconfig is not recommended by the official.

gaojinhsu avatar Oct 15 '20 08:10 gaojinhsu

My error:

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

This solution doesn't work for me:

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

My podspec:

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

Anyone have an idea how to fix this issue?

update: if I add --exclude-deps flag, it works, but my framework doesn't include dependencies.

shmueldw avatar Oct 22 '20 02:10 shmueldw

I solved this problem by modifying the local cocoapods-packager source ruby code. Modified .rb file's path:

/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/pod_utils.rb

I had inserted the build setting after line32:

    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

I hope that will help you guys.

JumChou avatar Oct 24 '20 12:10 JumChou

I solved this problem by modifying the local cocoapods-packager source ruby code. Modified .rb file's path:

/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/pod_utils.rb

I had inserted the build setting after line32:

    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

I hope that will help you guys.

Thanks a lot, It works for me.

shmueldw avatar Oct 25 '20 07:10 shmueldw

I solved this problem by modifying the local cocoapods-packager source ruby code. Modified .rb file's path:

/Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/pod_utils.rb

I had inserted the build setting after line32:

    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

I hope that will help you guys.

I have add this, but it still cannot run.

liuchen195 avatar Nov 06 '20 08:11 liuchen195

sudo vim /Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/pod_utils.rb

config.build_settings['CLANG_MODULES_AUTOLINK'] = 'NO' config.build_settings['GCC_GENERATE_DEBUGGING_SYMBOLS'] = 'NO' config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*'] = 'arm64' // add this row

XuweiQT avatar Dec 23 '20 01:12 XuweiQT

sudo vi /Library/Ruby/Gems/2.6.0/gems/cocoapods-packager-1.5.0/lib/cocoapods-packager/builder.rb

---
 lib/cocoapods-packager/builder.rb | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/cocoapods-packager/builder.rb b/lib/cocoapods-packager/builder.rb
index 009d94c..5241557 100755
--- a/lib/cocoapods-packager/builder.rb
+++ b/lib/cocoapods-packager/builder.rb
@@ -316,6 +316,11 @@ MAP
         args = "#{args} CODE_SIGN_IDENTITY=\"\" CODE_SIGNING_REQUIRED=NO"
       end
 
+      # fixed: iphonesimulator and iphoneos have the same architectures (arm64) and can't be in the same fat output file
+      if build_dir == 'build-sim'
+        build_dir = build_dir + " EXCLUDED_ARCHS=\"arm64\""
+      end
+
       command = "xcodebuild #{defines} #{args} CONFIGURATION_BUILD_DIR=#{build_dir} clean build -configuration #{config} -target #{target} -project #{project_root}/Pods.xcodeproj 2>&1"
       output = `#{command}`.lines.to_a
 
-- 

Best regards.

zhangyinglong avatar Jan 22 '21 04:01 zhangyinglong

Hello,Xcode 12.4 pod package 出现底层SDK找不到问题 image

initGalen avatar Feb 26 '21 06:02 initGalen

try https://github.com/TyrantDante/cocoapods-framework.git

TyrantDante avatar Mar 25 '21 13:03 TyrantDante

Having the same issue but i386 :(

Error: have the same architectures (i386) and can't be in the same fat output file

The modified BitcoinKit.podspec File:

Changed:

'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',
spec.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }

Pod::Spec.new do |spec|
  spec.name = 'BitcoinKit'
  spec.version = '1.1.0'
  spec.summary = 'Bitcoin(BCH/BTC) protocol toolkit for Swift'

  spec.description = <<-DESC
                       The BitcoinKit library is a Swift implementation of the Bitcoin(BCH/BTC) protocol. This library was originally made by Katsumi Kishikawa, and now is maintained by Yenom Inc. It allows maintaining a wallet and sending/receiving transactions without needing a full blockchain node. It comes with a simple wallet app showing how to use it.
                       ```
                    DESC
  spec.homepage = 'https://github.com/yenom/BitcoinKit'
  spec.license = { :type => 'MIT', :file => 'LICENSE' }
  spec.author = { 'BitcoinKit developers' => '[email protected]' }

  spec.requires_arc = true
  spec.source = { git: 'https://github.com/yenom/BitcoinKit.git', tag: "v#{spec.version}" }
  spec.source_files = 'BitcoinKit/**/*.{h,m,swift}', 'Sources/BitcoinKit/**/*.{h,m,swift}'
  spec.private_header_files = 'BitcoinKit/**/BitcoinKitPrivate.h'
  spec.exclude_files = 'Sources/**/LinuxSupport.swift'
  spec.module_map = 'BitcoinKit/BitcoinKit.modulemap'
  spec.ios.deployment_target = '8.0'
  spec.swift_version = '5.0'

  spec.pod_target_xcconfig = { 'SWIFT_WHOLE_MODULE_OPTIMIZATION' => 'YES',
			      
			      'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',

                               'APPLICATION_EXTENSION_API_ONLY' => 'YES',
                               'SWIFT_INCLUDE_PATHS' => '${PODS_ROOT}/BitcoinKit/Libraries',
                               'HEADER_SEARCH_PATHS' => '"${PODS_ROOT}/BitcoinKit/Libraries/openssl/include" "${PODS_ROOT}/BitcoinKit/Libraries/secp256k1/include"',
                               'LIBRARY_SEARCH_PATHS' => '"${PODS_ROOT}/BitcoinKit/Libraries/openssl/lib" "${PODS_ROOT}/BitcoinKit/Libraries/secp256k1/lib"',
                               'OTHER_SWIFT_FLAGS' => '-D BitcoinKitXcode' }

  spec.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }

  spec.preserve_paths = ['setup', 'Libraries']
  spec.prepare_command = 'sh setup/build_libraries.sh'
end


Xcode 13.2 macOS Big Sur (11.5.2) Apple Macbook M1

Thanks for Help

SurpriseMF3000 avatar Mar 15 '22 15:03 SurpriseMF3000