ios Xcode 构建选项“启用位码”的影响是/否
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31088618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Impact of Xcode build options "Enable bitcode" Yes/No
提问by luk2302
Yesterday I recognized a ton of warnings regarding the parse.com library:
昨天我发现了大量关于 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.
紧急:所有位码都将被删除,因为 '[path]/Parse.framework/Parse(PFAnalytics.o)' 是在没有位码的情况下构建的。您必须在启用位码的情况下重建它(Xcode 设置 ENABLE_BITCODE),从供应商处获取更新的库,或为此目标禁用位码。注意:这将是未来的错误。
I am aware of the fact that I can remove those warning with this answerbut am now wondering if it will have any negative impact in regards to AppStore submission and / or actual performance of my app.
我知道我可以使用此答案删除这些警告,但现在想知道它是否会对 AppStore 提交和/或我的应用程序的实际性能产生任何负面影响。
Xcode informs you regarding bitcode
Xcode 会通知您有关位码的信息
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]
激活此设置表示目标或项目应在编译期间为支持它的平台和体系结构生成位代码。对于存档构建,将在链接的二进制文件中生成位代码以提交到应用商店。对于其他构建,编译器和链接器将检查代码是否符合位码生成的要求,但不会生成实际的位码。[ENABLE_BITCODE]
But I am not getting any really useful information out of this text.
但是我没有从这篇文章中得到任何真正有用的信息。
- 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? - Are there any performance impacts if I enable / disable it?
- 我可以使用链接的答案来规避问题而不产生任何负面影响并且不影响未来的 AppStore 提交吗?
- 什么是
ENABLE_BITCODE
真正做的,它会在未来的非强制性要求? - 如果我启用/禁用它,是否有任何性能影响?
回答by Jeffery Thomas
- What does the ENABLE_BITCODE actually do, will it be a non-optional requirement in the future?
- ENABLE_BITCODE 实际上是做什么的,将来会不会成为非可选要求?
I'm not sure at what level you are looking for an answer at, so let's take a little trip. Some of this you may already know.
我不确定您在什么级别上寻找答案,所以让我们走一趟。其中一些您可能已经知道。
When you build your project, Xcode invokes clang
for Objective-C targets and swift
/swiftc
for Swift targets. Both of these compilers compile the app to an 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.
当您构建项目时,Xcode 会clang
为 Objective-C 目标和swift
/swiftc
为 Swift 目标调用。这两个编译器都将应用程序编译为中间表示(IR),这些 IR 之一是位码。从这个 IR 中,一个名为 LLVM 的程序接管并创建 x86 32 和 64 位模式(用于模拟器)和 arm6/arm7/arm7s/arm64(用于设备)所需的二进制文件。通常,所有这些不同的二进制文件都集中在一个名为fat binary 的文件中。
The ENABLE_BITCODE option cuts out this final step. It creates a version of the app with an IR bitcode binary. This has a number of nice features, but one giant drawback: it can't run anywhere. In order to get an app with a bitcode binary to run, the bitcode needs to be recompiled (maybe assembled or transcoded… I'm not sure of the correct verb) into an x86 or ARM binary.
ENABLE_BITCODE 选项取消了这最后一步。它使用 IR 位码二进制文件创建应用程序版本。它有许多不错的功能,但有一个巨大的缺点:它不能在任何地方运行。为了让带有二进制位代码的应用程序运行,位代码需要重新编译(可能是组装或转码……我不确定正确的动词)为 x86 或 ARM 二进制文件。
When a bitcode app is submitted to the App Store, Apple will do this final step and create the finished binaries.
当一个 bitcode 应用程序提交到 App Store 时,Apple 将执行最后一步并创建完成的二进制文件。
Right now, bitcode apps are optional, but history has shown Apple turns optional things into requirements (like 64 bit support). This usually takes a few years, so third party developers (like Parse) have time to update.
现在,bitcode 应用程序是可选的,但历史表明 Apple 将可选的东西变成了要求(比如 64 位支持)。这通常需要几年时间,因此第三方开发人员(如 Parse)有时间进行更新。
- can I use the above method without any negative impact and without compromising a future appstore submission?
- 我可以使用上述方法而不会产生任何负面影响并且不影响未来的应用商店提交吗?
Yes, you can turn off ENABLE_BITCODE and everything will work just like before. Until Apple makes bitcode apps a requirement for the App Store, you will be fine.
是的,您可以关闭 ENABLE_BITCODE,一切都会像以前一样工作。在 Apple 将比特码应用程序作为 App Store 的一项要求之前,您会没事的。
- Are there any performance impacts if I enable / disable it?
- 如果我启用/禁用它,是否有任何性能影响?
There will never be negative performance impacts for enabling it, but internal distribution of an app for testing may get more complicated.
启用它永远不会有负面的性能影响,但用于测试的应用程序的内部分发可能会变得更加复杂。
As for positive impacts… well that's complicated.
至于积极影响……嗯,这很复杂。
For distribution in the App Store, Apple will create separate versions of your app for each machine architecture (arm6/arm7/arm7s/arm64) instead of one app with a fat binary. This means the app installed on iOS devices will be smaller.
为了在 App Store 中分发,Apple 将为每种机器架构 (arm6/arm7/arm7s/arm64) 创建单独的应用程序版本,而不是一个带有胖二进制文件的应用程序。这意味着安装在 iOS 设备上的应用会更小。
In addition, when bitcode is recompiled (maybe assembled or transcoded… again, I'm not sure of the correct verb), it is optimized. LLVM is always working on creating new a better optimizations. In theory, the App Store could recreate the separate version of the app in the App Store with each new release of LLVM, so your app could be re-optimized with the latest LLVM technology.
此外,当重新编译 bitcode 时(可能是组装或转码......同样,我不确定正确的动词),它会被优化。LLVM 一直致力于创建新的更好的优化。理论上,App Store 可以随着 LLVM 的每个新版本在 App Store 中重新创建应用程序的单独版本,因此您的应用程序可以使用最新的 LLVM 技术重新优化。
回答by Gamma-Point
回答by agy
Bitcode is a new feature of iOS 9
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
位码是已编译程序的中间表示。您上传到 iTunes Connect 的包含 bitcode 的应用程序将在 App Store 上编译和链接。包含 bitcode 将允许 Apple 将来重新优化您的应用程序二进制文件,而无需向商店提交新版本的应用程序。
注意:对于 iOS 应用程序,bitcode 是默认值,但可选。如果您提供 bitcode,则应用程序包中的所有应用程序和框架都需要包含 bitcode。对于 watchOS 应用程序,需要位码
So you should disabled bitcode until all the frameworks of your app have bitcode enabled.
所以你应该禁用 bitcode,直到你的应用程序的所有框架都启用了 bitcode。
回答by Alexander Vasenin
Bitcode makes crash reporting harder. Here is a quote from HockeyApp(which also true for any othercrash reporting solutions):
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.
当将应用程序上传到 App Store 并启用“Bitcode”复选框时,Apple 将使用该 Bitcode 构建并在将其分发到设备之前重新编译它。这将导致二进制文件获得新的 UUID,并且可以选择通过 Xcode 下载相应的 dSYM。
Note: the answer was edited on Jan 2016 to reflect most recent changes
注意:答案于 2016 年 1 月进行了编辑以反映最近的变化
回答by zszen
回答by Rex
Here you can find all the solution regarding Bitcode
在这里您可以找到有关Bitcode 的所有解决方案
As per Apple Doc
根据 Apple Doc
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 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.
Xcode hides symbols generated during build time by default, so they are not readable by Apple. Only if you choose to include symbols when uploading your app to iTunes Connect would the symbols be sent to Apple. You must include symbols to receive crash reports from Apple.
Note:For iOS apps, bitcode is the default, but optional. For watchOS and tvOS apps, bitcode is required. If you provide bitcode, all apps and frameworks in the app bundle (all targets in the project) need to include bitcode. After you distribute your app using iTunes Connect, you can download the dSYMs file for the build, described in Viewing and Importing Crashes in the Devices Window
Apple's initial roll-out of the bitcode and app thinning service was put on hold, because issues in upgrading from one type of hardware to a different type of hardware didn't restore the right versions of binaries. This issue was subsequently fixed with iOS 9.0.2 and the feature re-enabled.
Bitcode has always been a part of the LLVM compile and optimisation phases, but by moving the back-end logic to the Apple servers, it moves the optimise and assemble phases from developer compile time to App Store deployment. This unlocks the potential of future re-optimisation or re-translation to support newer and faster processors in future. Bitcode deployments are required for watchOS and tvOS deploments, and can be conditionally enabled for existing iOS deployments with the "Enable Bitcode" option in the project settings. This will add a flag embed-bitcode-marker for debug builds, and embed-bitcode for archive/device builds. These can be passed to the Swift compiler with -embed-bitcode or by using clang with -fembed-bitcode.
Bitcode also has some disadvantages.Developers can debug crash reports from applications by storing copies of the debug symbols corresponding to the binary that was shipped to Apple. When a crash happens in a given stack, the developer can restore the original stack trace by symbolicating the crash report, using these debug symbols. However, the symbols are a by-product of translating the intermediate form to the binary; but if that step is done on the server, this information is lost. Apple provides a crash reporting service that can play the part of the debugger, provided that the developer has uploaded the debug symbols at the time of application publication. The fact that the developer never sees the exact binary means that they may not be able to test for speciic issues as new hardware evolves. There are also some concerns about ceding power to Apple to perform compilation – including the ability to inject additional routines or code snippets – but since Apple is in full control of the publication process these are currently possible whether or not the developer uses bitcode or compiled binaries.
Finally, the bitcodeon the server can be translated to support new architectures and instruction sets as they evolve. Provided that they maintain the calling convention and size of the alignment and words, a bitcode application might be translated into different architecture types and optimised specifically for a new processor. If standard libraries for math and vector routines are used, these can be optimised into processor specific vector instructions to gain the best performance for a given application. The optimisers might even generate multiple different encodings and judge based on size or execution speed.
位码是已编译程序的中间表示。您上传到 iTunes Connect 的包含 bitcode 的应用程序将在商店中编译和链接。包含 bitcode 将允许 Apple 将来重新优化您的应用程序二进制文件,而无需向商店提交新版本的应用程序。
默认情况下,Xcode 隐藏在构建期间生成的符号,因此 Apple 无法读取它们。仅当您在将应用程序上传到 iTunes Connect 时选择包含符号时,这些符号才会发送给 Apple。您必须包含符号才能从 Apple 接收崩溃报告。
注意:对于 iOS 应用程序,bitcode 是默认值,但可选。对于 watchOS 和 tvOS 应用程序,位码是必需的。如果您提供 bitcode,则应用程序包中的所有应用程序和框架(项目中的所有目标)都需要包含 bitcode。使用 iTunes Connect 分发应用程序后,您可以下载构建的 dSYMs 文件,如在设备窗口中查看和导入崩溃中所述
Apple 最初推出的 bitcode 和应用程序精简服务被搁置,因为从一种类型的硬件升级到另一种类型的硬件时出现问题并没有恢复正确版本的二进制文件。此问题随后在 iOS 9.0.2 中得到修复并重新启用该功能。
Bitcode 一直是 LLVM 编译和优化阶段的一部分,但通过将后端逻辑移至 Apple 服务器,它将优化和组装阶段从开发人员编译时移至 App Store 部署。这释放了未来重新优化或重新转换的潜力,以支持未来更新和更快的处理器。watchOS 和 tvOS 部署需要 Bitcode 部署,并且可以通过项目设置中的“启用 Bitcode”选项为现有的 iOS 部署有条件地启用。这将为调试构建添加一个标志 embed-bitcode-marker,并为存档/设备构建添加一个 embed-bitcode。这些可以通过 -embed-bitcode 或使用带有 -fembed-bitcode 的 clang 传递给 Swift 编译器。
比特码也有一些缺点。开发人员可以通过存储与发送给 Apple 的二进制文件对应的调试符号的副本来调试来自应用程序的崩溃报告。当给定堆栈中发生崩溃时,开发人员可以使用这些调试符号通过符号化崩溃报告来恢复原始堆栈跟踪。但是,符号是将中间形式转换为二进制的副产品;但是如果这一步在服务器上完成,这个信息就会丢失。Apple 提供了一个崩溃报告服务,可以扮演调试器的角色,前提是开发者在应用程序发布时上传了调试符号。开发人员从未看到确切的二进制文件这一事实意味着,随着新硬件的发展,他们可能无法测试特定问题。
最后,服务器上的位码可以被翻译以支持新的架构和指令集随着它们的发展。如果它们保持调用约定和对齐和字的大小,位码应用程序可能会被转换为不同的体系结构类型并专门针对新处理器进行优化。如果使用数学和向量例程的标准库,它们可以优化为处理器特定的向量指令,以获得给定应用程序的最佳性能。优化器甚至可能生成多种不同的编码,并根据大小或执行速度进行判断。
回答by vj9
From the docs
从文档
- can I use the above method without any negative impact and without compromising a future appstore submission?
- 我可以使用上述方法而不会产生任何负面影响并且不影响未来的应用商店提交吗?
Bitcode will allow apple to optimise the app without you having to submit another build. But, you can only enable this feature if all frameworks and apps in the app bundle have this feature enabled. Having it helps, but not having it should not have any negative impact.
Bitcode 将允许苹果优化应用程序,而无需提交另一个构建。但是,只有在应用程序包中的所有框架和应用程序都启用了此功能时,您才能启用此功能。拥有它有帮助,但没有它不应该有任何负面影响。
- What does the ENABLE_BITCODE actually do, will it be a non-optional requirement in the future?
- 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.
对于 iOS 应用程序,位码是默认的,但可选的。如果您提供 bitcode,则应用程序包中的所有应用程序和框架都需要包含 bitcode。对于 watchOS 应用程序,位码是必需的。
- Are there any performance impacts if I enable / disable it?
- 如果我启用/禁用它,是否有任何性能影响?
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.
App Store 和操作系统通过根据用户特定设备的功能定制应用程序交付,以最小的占用空间来优化 iOS 和 watchOS 应用程序的安装。这种优化称为应用程序精简,可让您创建使用最多设备功能、占用最少磁盘空间并适应 Apple 可以应用的未来更新的应用程序。其他应用程序和内容的更快下载和更多空间提供了更好的用户体验。
There should not be any performance impacts.
不应该有任何性能影响。