Viktor Vostrikov
Viktor Vostrikov

Reputation: 1522

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..

Upvotes: 9

Views: 4873

Answers (2)

Vasily  Bodnarchuk
Vasily Bodnarchuk

Reputation: 25294

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

Upvotes: 1

Simon
Simon

Reputation: 1737

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

Upvotes: 9

Related Questions