Xcode 构建选项的影响 "Enable bitcode" Yes/No

Impact of Xcode build options "Enable bitcode" Yes/No

昨天我发现了大量关于 parse.com 库的警告:

URGENT: all bitcode will be dropped because '[path]/Parse.framework/Parse(PFAnalytics.o)' was built without 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. Note: This will be an error in the future.

我知道我可以使用 删除这些警告,但我现在想知道它是否会对 AppStore 提交和/或我的应用程序的实际性能产生任何负面影响。

Xcode 通知您有关 bitcode

Activating this setting indicates that the target or project should generate bitcode during compilation for platforms and architectures which support it. For Archive builds, bitcode will be generated in the linked binary for submission to the app store. For other builds, the compiler and linker will check whether the code complies with the requirements for bitcode generation, but will not generate actual bitcode. [ENABLE_BITCODE]

但是我没有从这篇文章中得到任何真正有用的信息。

Bitcode 是 iOS 9

的新功能

Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store. Including bitcode will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to the store.

Note: For iOS apps, bitcode is the default, but optional. If you provide bitcode, all apps and frameworks in the app bundle need to include bitcode. For watchOS apps, bitcode is required

所以你应该禁用位码,直到你的应用程序的所有框架都启用了位码。

来自docs

  • 我可以使用上述方法而不会产生任何负面影响并且不会影响未来的应用商店提交吗?

Bitcode 将允许 apple 优化应用程序,而无需您提交另一个版本。但是,如果应用程序包中的所有框架和应用程序都启用了此功能,则只能启用此功能。 有它有帮助,但没有它应该不会有任何负面影响。

  • ENABLE_BITCODE实际上是做什么的,将来会成为非可选要求吗?

For iOS apps, bitcode is the default, but optional. If you provide bitcode, all apps and frameworks in the app bundle need to include bitcode. For watchOS apps, bitcode is required.

  • 如果我启用/禁用它是否会影响性能?

The App Store and operating system optimize the installation of iOS and watchOS apps by tailoring app delivery to the capabilities of the user’s particular device, with minimal footprint. This optimization, called app thinning, lets you create apps that use the most device features, occupy minimum disk space, and accommodate future updates that can be applied by Apple. Faster downloads and more space for other apps and content provides a better user experience.

应该不会有任何性能影响。

  • What does the ENABLE_BITCODE actually do, will it be a non-optional requirement in the future?

我不确定您在哪个级别寻找答案,所以让我们来一次小旅行。其中一些您可能已经知道。

构建项目时,Xcode 为 Objective-C 目标调用 clang,为 Swift 目标调用 swift/swiftc。这两个编译器都将应用程序编译为 intermediate representation (IR), one of these IRs is bitcode. From this IR, a program called LLVM takes over and creates the binaries needed for x86 32 and 64 bit modes (for the simulator) and arm6/arm7/arm7s/arm64 (for the device). Normally, all of these different binaries are lumped together in a single file called a fat binary.

ENABLE_BITCODE 选项删除了这最后一步。它使用 IR 位码二进制文件创建应用程序版本。它有许多不错的功能,但有一个巨大的缺点:它不能 运行 任何地方。为了得到一个二进制位码为 运行 的应用程序,需要重新编译位码(可能会组装或转码......我不确定正确的动词)到x86 或 ARM 二进制文件。

将 bitcode 应用程序提交到 App Store 后,Apple 将执行最后一步并创建完成的二进制文件。

现在,bitcode 应用程序是可选的,但历史表明 Apple 将可选的东西变成了必需的(比如 64 位支持)。这通常需要几年时间,因此第三方开发人员(如 Parse)有时间更新。

  • can I use the above method without any negative impact and without compromising a future appstore submission?

是的,您可以关闭 ENABLE_BITCODE,一切都会像以前一样工作。在 Apple 将 bitcode 应用程序作为 App Store 的要求之前,您会没事的。

  • Are there any performance impacts if I enable / disable it?

启用它永远不会对性能产生负面影响,但用于测试的应用程序的内部分发可能会变得更加复杂。

至于积极影响……嗯,这很复杂。

为了在 App Store 中分发,Apple 将为每个机器架构 (arm6/arm7/arm7s/arm64) 创建您的应用程序的单独版本,而不是一个具有胖二进制文件的应用程序。这意味着 iOS 台设备上安装的应用会更小。

此外,当 bitcode 被重新编译时(可能被组装或转码......同样,我不确定正确的动词),它被优化了。 LLVM 一直致力于创造新的更好的优化。理论上,App Store 可以在每次发布新的 LLVM 时在 App Store 中重新创建应用程序的单独版本,因此您的应用程序可以使用最新的 LLVM 技术重新优化。

确保 select "All" 找到启用位码构建设置:

Bitcode 使崩溃报告变得更加困难。这是来自 HockeyApp 的引述(对于 任何其他 崩溃报告解决方案也是如此):

When uploading an app to the App Store and leaving the "Bitcode" checkbox enabled, Apple will use that Bitcode build and re-compile it on their end before distributing it to devices. This will result in the binary getting a new UUID and there is an option to download a corresponding dSYM through Xcode.

注意:答案于 2016 年 1 月编辑以反映最近的更改

@vj9 谢谢。我更新到 xcode 7 。它告诉我同样的错误。设置好后构建"NO"

设置"NO"效果不错

Can I use the linked answer to circumvent the issue without any negative impact and without compromising a future AppStore submission?

What does the ENABLE_BITCODE actually do, will it be a non-optional requirement in the future?

ENABLE_BITCODE 将代码的中间表示形式添加到二进制文件中。对于 watchOS、tvOS 现在是强制性的

Are there any performance impacts if I enable / disable it?

当您归档您的项目

时,它会对Xcode构建和内存占用产生影响