Xcode 构建选项“启用位码"的影响是/否 [英] Impact of Xcode build options "Enable bitcode" Yes/No

查看:25
本文介绍了Xcode 构建选项“启用位码"的影响是/否的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Yesterday I recognized a ton of warnings regarding the parse.com library:

紧急:所有位码都将被删除,因为 '[path]/Parse.framework/Parse(PFAnalytics.o)' 是在没有位码的情况下构建的.您必须在启用位码的情况下重建它(Xcode 设置 ENABLE_BITCODE),从供应商处获取更新的库,或为此目标禁用位码.注意:这在以后会出错.

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 提交和/或我的应用的实际性能的任何负面影响.

I am aware of the fact that I can remove those warning with this answer but am now wondering if it will have any negative impact in regards to AppStore submission and / or actual performance of my app.

Xcode 通知您有关位码的信息

Xcode informs you regarding bitcode

激活此设置表示目标或项目应在编译期间为支持它的平台和架构生成位代码.对于存档构建,将在链接的二进制文件中生成位代码以提交到应用程序商店.对于其他构建,编译器和链接器将检查代码是否符合位码生成的要求,但不会生成实际的位码.[ENABLE_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]

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

But I am not getting any really useful information out of this text.

  • 我是否可以使用链接的答案来规避该问题,而不会产生任何负面影响并且不影响未来的 AppStore 提交?
  • ENABLE_BITCODE 的实际作用是什么,将来会成为非可选要求吗?
  • 如果我启用/禁用它会对性能产生任何影响吗?
  • 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?

推荐答案

  • 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.

当您构建项目时,Xcode 为 Objective-C 目标调用 clang,为 Swift 目标调用 swift/swiftc.这两个编译器都将应用编译为 中间表示 (IR),这些 IR 之一是位码.从这个 IR 中,一个名为 LLVM 的程序接管并创建 x86 32 和 64 位模式(用于模拟器)和 arm6/arm7/arm7s/arm64(用于设备)所需的二进制文件.通常,所有这些不同的二进制文件都集中在一个名为 fat 二进制文件.

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.

ENABLE_BITCODE 选项取消了这最后一步.它使用 IR 位码二进制文件创建应用程序版本.它有许多不错的功能,但有一个巨大的缺点:它不能在任何地方运行.为了让带有二进制二进制代码的应用程序运行,需要将二进制二进制代码重新编译(可能是汇编或转码……我不确定正确的动词)为 x86 或 ARM 二进制文件.

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.

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

When a bitcode app is submitted to the App Store, Apple will do this final step and create the finished binaries.

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

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.

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

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

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.

  • 如果我启用/禁用它会对性能产生任何影响吗?

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

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.

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

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.

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

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.

这篇关于Xcode 构建选项“启用位码"的影响是/否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆