今天试着用Xcode 7 beta 3在真机(iOS 8.3)上运行一下咱们的工程,结果发现工程编译不过。看了下问题,报的是如下错误:
html
1
|
ld: ‘/Users
/**/
Framework/SDKs/PolymerPay/Library/mobStat/lib**SDK.a(**ForSDK.o)’ 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.
for
architecture arm64
|
获得的信息是咱们引入的一个第三方库不包含bitcode。嗯,不知道bitcode是啥,因此就得先看看这货是啥了。ios
Bitcode是什么?xcode
找东西嘛,最早想到的固然是先看官方文档了。在App Distribution Guide – App Thinning (iOS, watchOS)一节中,找到了下面这样一个定义:app
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.ide
说的是bitcode是被编译程序的一种中间形式的代码。包含bitcode配置的程序将会在App store上被编译和连接。bitcode容许苹果在后期从新优化咱们程序的二进制文件,而不须要咱们从新提交一个新的版本到App store上。优化
嗯,看着挺高级的啊。ui
继续看,在What’s New in Xcode-New Features in Xcode 7中,还有一段以下的描述this
Bitcode. When you archive for submission to the App Store, Xcode will compile your app into an intermediate representation. The App Store will then compile the bitcode down into the 64 or 32 bit executables as necessary.spa
当咱们提交程序到App store上时,Xcode会将程序编译为一个中间表现形式(bitcode)。而后App store会再将这个botcode编译为可执行的64位或32位程序。code
再看看这两段描述都是放在App Thinning(App瘦身)一节中,能够看出其与包的优化有关了。喵大(@onevcat)在其博客开发者所须要知道的 iOS 9 SDK 新特性中也描述了iOS 9中苹果在App瘦身中所作的一些改进,你们能够转场到那去研读一下。
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. for architecture arm64
要么让第三方库支持,要么关闭target的bitcode选项。
实际上在Xcode 7中,咱们新建一个iOS程序时,bitcode选项默认是设置为YES的。咱们能够在”Build Settings”->”Enable Bitcode”选项中看到这个设置。
不过,咱们如今须要关注的是三个平台:iOS,Mac OS,watchOS。
对应iOS,bitcode是可选的。
对于watchOS,bitcode是必须的。
Mac OS不支持bitcode。
若是咱们开启了bitcode,在提交包时,下面这个界面也会有个bitcode选项:
盗图,个人应用没办法在这个界面显示bitcode,由于依赖于第三方的库,而这个库不支持bitcode,暂时只能设置ENABLE_BITCODE为NO。
因此,若是咱们的工程须要支持bitcode,则必要要求全部的引入的第三方库都支持bitcode。我就只能等着公司那些大哥大姐们啥时候提供一个新包给咱们了。
题外话
如上面所说,bitcode是一种中间代码。LLVM官方文档有介绍这种文件的格式,有兴趣的能够移步LLVM Bitcode File Format。