1

I have "Enable Bitcode" set to YES in my Build Settings.

When I archive my framework in Xcode 9.2 with the default toolchain:

enter image description here

and then run the command to check if bitcode is in the binary otool -arch arm64 -l MyFrameworkBinary | grep __LLVM, it produces the following output:

segname __LLVM
 segname __LLVM

If I change to the Swift 4.1 toolchain (https://swift.org/builds/swift-4.1-release/xcode/swift-4.1-RELEASE/swift-4.1-RELEASE-osx.pkg):

enter image description here

then run otool -arch arm64 -l MyFrameworkBinary | grep __LLVM, it doesn't produce any output.

Why does changing the Toolchain no longer honor the "Enable Bitcode" Build Setting?

UPDATE:

I noticed the Swift 4.1 toolchain contains an Info.plist with the following override:

enter image description here

but the problem is if I edit the Info.plist, Xcode will no longer use that toolchain as it complains that the plist/signature has changed. I even tried running xcodebuild from command line and specifying the Swift 4.1 toolchain, but it also just falls back to the default Xcode 9.2 toolchain.

When building with xcodebuild and NOT editing the Info.plist, I get a few errors like the following:

ld: warning: Auto-Linking supplied 
'/Library/Developer/Toolchains/swift-4.1-RELEASE.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib', 
'/Library/Developer/Toolchains/swift-4.1-RELEASE.xctoolchain/usr/lib/swift/iphoneos/libswiftCore.dylib' 
does not contain bitcode. 
You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), 
obtain an updated library from the vendor, 
or disable bitcode for this target.

so it appears that maybe the toolchain releases don't ship the Swift libraries with bitcode enabled which means I'm probably just S.O.L.

Adam Johns
  • 32,040
  • 21
  • 108
  • 161
  • first let me say that I dont know... but there may be a hint on: https://stackoverflow.com/questions/31205133/how-to-enable-bitcode-in-xcode-7 it says that all of the products linked need to enable bitcode... perhaps you are linking something that doesn't? – Grady Player Apr 05 '18 at 20:51
  • I figured out in the Swift 4.1 Release toolchain there is an Info.plist that has a setting for overriding ENABLE_BITCODE and setting it to NO (no idea why). The problem is if I try to remove that override from the plist, Xcode won't let me select that toolchain anymore because it says the plist has been modified. – Adam Johns Apr 05 '18 at 22:23
  • I haven't updated to xcode 9 yet, but there is a `manage toolchains...` menu item... can you duplicate it and fix it in the duplicate? – Grady Player Apr 06 '18 at 01:17
  • @GradyPlayer, good suggestion but unfortunately Xcode won't even pick it up as an option after duplicating it. Also I don't think it would matter anyways since it looks like the Swift libs themselves aren't shipped with bitcode enabled for the toolchain releases (probably why the override is there). See my latest update for more details. – Adam Johns Apr 06 '18 at 01:22

1 Answers1

0

It appears the Swift dylibs that ship with the Toolchain releases do not include bitcode which is the root cause of the issue.

If I download the Swift 4.1 release toolchain and navigate to /Library/Developer/Toolchains/swift-4.1-RELEASE.xctoolchain/usr/lib/swift/iphoneos and run otool -l libswiftCore.dylib | grep __LLVM there is no output (indicating the libs don't contain bitcode).

However, if I run the same otool command inside /Applications/Xcode_9.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos, I see the following output:

segname __LLVM
 segname __LLVM
segname __LLVM
 segname __LLVM
segname __LLVM
 segname __LLVM

This must be why the toolchain ships with the plist override mentioned in my original question.

It appears that there is no workaround for this unfortunately (other than just using Xcode 9.3 to make the build).

Adam Johns
  • 32,040
  • 21
  • 108
  • 161