Xcode并不尊重"启用Bitcode = YES"使用不同的工具链进行归档时

时间:2018-04-05 20:47:03

标签: ios xcode

我有"启用Bitcode"在我的构建设置中设置为

当我使用默认工具链在Xcode 9.2中存档我的框架时:

enter image description here

然后运行命令检查bitcode是否在二进制文件otool -arch arm64 -l MyFrameworkBinary | grep __LLVM中,它会产生以下输出:

segname __LLVM
 segname __LLVM

如果我更改为Swift 4.1工具链(https://swift.org/builds/swift-4.1-release/xcode/swift-4.1-RELEASE/swift-4.1-RELEASE-osx.pkg):

enter image description here

然后运行otool -arch arm64 -l MyFrameworkBinary | grep __LLVM,它不会产生任何输出。

为什么更改工具链不再遵守"启用Bitcode"构建设置?

更新

我注意到Swift 4.1工具链包含一个带有以下覆盖的Info.plist:

enter image description here

但问题是如果我编辑Info.plist,Xcode将不再使用该工具链,因为它抱怨plist /签名已更改。我甚至尝试从命令行运行xcodebuild并指定Swift 4.1工具链,但它也只是回到默认的Xcode 9.2工具链。

使用xcodebuild构建并且不编辑Info.plist时,我会收到以下错误:

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.

所以似乎工具链发布可能不会在启用bitcode的情况下运送Swift库,这意味着我可能只是S.O.L。

1 个答案:

答案 0 :(得分:0)

与工具链版本一起发布的Swift dylib似乎不包括bitcode,这是问题的根本原因。

如果我下载Swift 4.1发布工具链并导航到/Library/Developer/Toolchains/swift-4.1-RELEASE.xctoolchain/usr/lib/swift/iphoneos并运行otool -l libswiftCore.dylib | grep __LLVM,则没有输出(表明libs不包含bitcode)。

但是,如果我在otool内运行相同的/Applications/Xcode_9.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos命令,我会看到以下输出:

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

这必须是工具链附带我原始问题中提到的plist覆盖的原因。

看起来很遗憾没有解决方法(除了使用Xcode 9.3进行构建之外)。