Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiled framework provides bitcode error when archiving

have been struggling for few days... Basically I have build a compiled released framework and distribute it with cocoaPods. The problem is that then archiving this framework application gets the following error:

ld: bitcode bundle could not be generated because '/.../testingPodsAcrossversions/Pods/Pod/Pod.framework/Pod' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build file '/.../testingPodsAcrossversions/Pods/Pod/Pod.framework/Pod' for architecture arm64

I have did these things:

Search for Enable Bitcode setting and set it to YES for Debug and Release modes. 

Search for bitcode settings. Add -fembed-bitcode in both Debug and Release modes or you can add -fembed-bitcode-marker in Debug and  -fembed-bitcode in Release mode.

Add BITCODE_GENERATION_MODE under User Defined setting , and then add bitcode for both Debug and Release modes or you can add markerin Debug and bitcode in Release mode.

I only need release version, so I did not built an universal framework, just release version... I would genuinely like to solve this issue, because it has been a nightmare for me..

like image 396
Viktor Vostrikov Avatar asked Jan 07 '19 21:01

Viktor Vostrikov


2 Answers

If you're using pods, try adding this to the Podfile (it resolved the same issue for me):

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['BITCODE_GENERATION_MODE'] = 'bitcode'
            config.build_settings['ENABLE_BITCODE'] = 'YES'
        end
    end
end
like image 147
Webfreak Avatar answered Nov 02 '22 23:11

Webfreak


Details

  • Xcode Version 11.3.1 (11C504)

Solution

Add the following code at the end of the podfile

def enable_bitcode_in(config)
  cflags = config.build_settings['OTHER_CFLAGS'] || ['$(inherited)']
  if config.name == 'Release'
    cflags << '-fembed-bitcode'
    config.build_settings['BITCODE_GENERATION_MODE'] = 'bitcode'
  else # 'Debug'
    cflags << '-fembed-bitcode-marker'
    config.build_settings['BITCODE_GENERATION_MODE'] = 'marker'
  end
  config.build_settings['OTHER_CFLAGS'] = cflags
end

def enable_bitcode_for(targets)
  targets.each do |target|
    target.build_configurations.each do |config|
      enable_bitcode_in(config)
    end
  end
end

post_install do |installer|
  enable_bitcode_for(installer.pods_project.targets)
end
like image 41
Vasily Bodnarchuk Avatar answered Nov 03 '22 00:11

Vasily Bodnarchuk