Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cjlcooper opened this issue Sep 30, 2020 · 14 comments

Comments

@cjlcooper
Copy link

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

@brave723
Copy link

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.

@tangguoan
Copy link

I tried, but I couldn't solve the problem

@Feng999
Copy link

Feng999 commented Oct 13, 2020

The problem is still there. Can anyone help?

@cjlcooper
Copy link
Author

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' }

@gaojinhsu
Copy link

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.

@shmueldw
Copy link

shmueldw commented Oct 22, 2020

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.

@JumChou
Copy link

JumChou commented Oct 24, 2020

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.

@shmueldw
Copy link

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.

@liuchen195
Copy link

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.

@XuweiQT
Copy link

XuweiQT commented Dec 23, 2020

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

@zhangyinglong
Copy link

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.

@initGalen
Copy link

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

@TyrantDante
Copy link

@SurpriseMF3000
Copy link

SurpriseMF3000 commented Mar 15, 2022

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

EkkoG added a commit to EkkoG/cocoapods-packager that referenced this issue Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests