xcodebuild 7.3 can't enable bitcode
Asked Answered
M

2

13

I'm developing an embbeded framework for iOS. In order to make an universal fat (with simulator and device slices), I created an aggregate target with a script that uses xcodebuild and lipo commands to generate it, as many people does.

With XCode 7.x I had to add an user-defined settings with BITCODE_GENERATION_MODE=bitcode in order to enable it, but this has stop working since the last XCode 7.3 release.

I've tried everything I found in the internet like add OTHER_CFLAGS="-fembed-bitcode", but anything works as before...

I have seen this in the build log:

enable_bitcode = NO

ENABLE_BITCODE is always NO, no matter I do.

Has anybody tried to create an universal fat framework with bitcode enabled using xcodebuild command since XCode 7.3?

Merrill answered 23/3, 2016 at 17:31 Comment(2)
We are tracking this issue at apple with bug # 25389361, which you can reference if you choose to file a duplicate bug or otherwise communicate about the issue. Thanks for raising the issue!Antoineantoinetta
This is resolved in the Xcode 8.0 beta released on June 13thAntoineantoinetta
E
17

I ran into a similar issue yesterday. After some investigation, the problem, that appears when running xcodebuild from a "Run Script" build phase in any Xcode target, seems related with the explicit specification of the toolchain to be used, done with the ENV variable TOOLCHAINS.

Therefore, until Apple releases a fixed version of Xcode 7.3, you can try to add the following command at the beginning of your script:

# workaround for bitcode generation problem with Xcode 7.3 unset TOOLCHAINS

This should be harmless, as this env variable is not set by default when you run xcodebuild from the command line, and this workaround works just fine in my case.

Educable answered 27/3, 2016 at 13:54 Comment(5)
As an Apple engineer I can confirm that this is an appropriate workaround.Antoineantoinetta
Thanks @RickBallard for this confirmation!Educable
@RickBallard any update in this for released v7.3.1? Please advice.Stargell
@HaritK This is resolved in the Xcode 8.0 beta released on June 13th.Antoineantoinetta
@RickBallard I appreciate your response. Though I am yet to get xCode 8 beta and try.Stargell
P
0

I'm facing the same issue. Just like you, BITCODE_GENERATION_MODE and OTHER_CFLAGS="-fembed-bitcode" are simply ignored, and my builds broke

I did notice that it sometimes work, and sometimes doesn't. It seems that if you build the framework (or aggreate target) for the simulator, the bitcode goes away, no matter what you have in the xcodebuild commands.

I'm using Xcode 7.3, and I have 2 targets : Static Library, and Aggregate target to make the fat framework.

What works for me when it builds a bitcode-less framework, is to:

  • Select the static library target (not the aggregate one), and pick "Generic iOS device"
  • Clean it
  • Select the static library target, but pick a simulator
  • Build it (works, even if it's instantaneous because it hasn't been cleaned)
  • Select the static library target, but pick "Generic iOS device" again.
  • Build it
  • Select the aggregate target for a "Generic iOS device"
  • Finally, build it
  • If this failed, start over. I sometimes need to do it two or three times before it works.

When I do that, my fat library ends up having bitcode.

You can check that your framework has bitcode support easily by running otool -arch armv7 -l <framework_path> | grep LLVM

In order to break it again, simply build the aggregate target for a simulator. The library will still be a fat one, but bitcode's gone.

Somebody surely can find a solution that works everytime, but at least it fixes the issue for me.

I certainly did not have to do that with Xcode 7.2, and I don't know how that works for pure CLI builds.

Prefer answered 24/3, 2016 at 14:27 Comment(1)
Thanks for your answer. The "solution" that I applied for my project was like yours. I was compiling "manually" (with XCode, no with the script) the framework for device and then simulator, and finally using my script only for merging them with lipo. But see the workaround from @jlj, you can still using your script with adding only one line.Greggrega

© 2022 - 2024 — McMap. All rights reserved.