Search code examples
iosxcodecocoapodsxcode11bitcode

Build a fat framework in xcode11 with full bitcode


What I am trying to do:

I am trying to build a cocoapods framework in xcode11 and then use it in an iOS SDK.

What I have tried:

  • Set Enable Bitcode to yes
  • Before building the framework, I have set Other C flags to -fembed-bitcode and -fembed-bitcode-marker respectively for release and debug.

  • I have also set user defined build setting to BITCODE_GENERATION_MODE as bitcode and marker.

  • Build for both simulator and device; setting build scheme to release.

  • Follow this article to build a fat framework using lipo.

What issue I am facing:

After releasing the pre-release version of the framework to Cocoapods, I install it in my SDK. The build for SDK fails for device(release) with the following message:

ld: bitcode bundle could not be generated because '/Users/sourobratasarkar/Library/Developer/Xcode/DerivedData/Beaconstac-dpnhqvwchyqaeyavlbmfsntqlgnn/Build/Products/Release-iphoneos/EddystoneScanner/EddystoneScanner.framework/EddystoneScanner' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build file '/Users/sourobratasarkar/Library/Developer/Xcode/DerivedData/Beaconstac-dpnhqvwchyqaeyavlbmfsntqlgnn/Build/Products/Release-iphoneos/EddystoneScanner/EddystoneScanner.framework/EddystoneScanner' for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It says the framework was built without full bitcode for architecture arm7.

Is there anything I am missing while building the framework? Using lipo -info I can see that arm7 architecture is present.

PS: The build succeeds for debug (both device and simulator) and release (simulator).


Solution

  • Turns out there was no issue in the way I built the framework. Adding the following to the Podfile of the SDK where I was using the framework resolved this 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