Compiled framework provides bitcode error when archiving
Asked Answered
V

2

9

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

Voidance answered 7/1, 2019 at 21:24 Comment(4)
Possible duplicate of: #53650261 The suggested answer there was: "Try to set Skip Install to YES and Embed Bitcode to YES in framework build settings." Does that help you?Rosemonde
@Muli no, I have commented on that question.. and it did not solved it... still trying, but feel kinda hopeless..Voidance
@ViktorVostrikov, have you found a solution to this? I am facing a similar issueDinadinah
Anecdotally: I needed OTHER_CFLAGS = "-fembed-bitcode";, OTHER_LDFLAGS = "-ObjC";, and BITCODE_GENERATION_MODE = bitcode; for getting a static Swift framework with an Obj-C bridge to work when Archiving a bitcode-enabled app that consumed it.Hypothesize
W
9

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
Wong answered 23/1, 2019 at 14:6 Comment(0)
C
1

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
Coopery answered 15/3, 2020 at 2:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.