3 Replies
      Latest reply on Jul 31, 2017 10:08 AM by ioliveira
      senpoc Level 1 Level 1 (0 points)

        I am trying to build a new bitcode-enabled tvOS framework whose details are as follows:


        Language used in Framework: Swift 3.0

        Type of Library: XYZ.framework

        Is it a Universal build (supporting both Simulator and Device)?: YES

        tvOS Deployment Target: 9.2 onwards


        I am building the framework from a script using xcodebuild command as per the following steps:

        1. Making a device build using the following command in script.

        xcodebuild -target "${FRAMEWORK_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -arch arm64 ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" -sdk appletvos


        2. Making a Simulator build using the following command in script.

        xcodebuild -target "${FRAMEWORK_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -arch x86_64 ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode-marker" -sdk appletvsimulator


        3. Making a Universal build using the following lipo command



        All the above 3 commands are executed successfully and an Universal framework is being built without any issues. But, when I try to verify if the final framework is bitcode enabled or not using the following commands, I am not getting any results.

             otool -l tvOSFramework.framework/tvOSFramework | grep __bitcode (or)

             otool -l tvOSFramework.framework/tvOSFramework | grep __LLVM


        When I try to include this framework in an application and try to archive the application (AppName: TestAppObjC written in Obj C) using XCode, archiving fails with the following error:

        Failed to verify bitcode in tvOSFramework.framework/tvOSFramework:

        error: Cannot extract bundle from /var/folders/9f/9sgckkbn7xx61p6m25kh80kc0000gn/T/IDEDistributionThinningStep.XFm/Payload/TestAppObjC.app/Frameworks/tvOSFramework.framework/tvOSFramework (x86_64)

        I had tried with setting BITCODE_GENERATION_MODE=bitcode also but the same issue occurs.


        Hence, I finally ended up in having two different versions of the framework one for device and one for the Simulator. But I would like to have an Universal framework instead with bitcode enabled.


        Can anybody let me know if there is a way to arrive at a bitcode enabled Universal Swift framework for tvOS?

        • Re: How to enable bitcode in Universal Swift framework for tvOS?
          edford Apple Staff Apple Staff (905 points)

          There are a few important details to consider:

          1. Distributing Swift frameworks that are built for later inclusion in an app is not supported, and is documented in the Xcode 8.0 release notes. You should setup your app project to build the framework as a dependency of the app target instead. See  Technical Note 2435, Embedding Frameworks In An App for how to setup a project like this.
          2. Universal frameworks that cover both a device and a simulator are not supported. You should build two frameworks instead, one for the device OS, the other for the simulator, as you say you are doing.
          3. If this was an Objective-C framework, you would need to do either an archive or an install build from xcodebuild to generate a build product that includes bitcode. When doing one of these build types, the only build setting that matters is the Enable Bitcode build setting on the framework target. See the man page for xcodebuild to see how to specifcy either an install or an archive build action.
          • Re: How to enable bitcode in Universal Swift framework for tvOS?
            ioliveira Level 1 Level 1 (0 points)

            Hi senpoc, how about distribution? Were you able to distribute those frameworks via cocoapods? I couldn't generate a tvOS framework with bitcode support enabled. I ended up using archive command to generate the framework. But the framework generated has only arm64 architecture. Cocoapods is complaining about it. The framework should have other architecture, also.


            Can you help me with this?


            Thanks in advance!