Bitcode的使用


Bitcode剛出來的時候查過相關的文檔,知道只要是iOS程序就把Enable Bitcode選擇NO,因爲那個時候第三方SDK都沒有支持Bitcode包,也就沒有細看,今天我們來看看什麼是Bitcode以及它的用法。

Bitcode是什麼

查看的官方文檔,在APPDistribution Guide–App Thinning (iOS, watchOS)一節中,找到了下面這樣一個定義:

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

說的是bitcode是被編譯程序的一種中間形式的代碼。包含bitcode配置的程序將會在App store上被編譯和鏈接。bitcode允許蘋果在後期重新優化程序的二進制文件,而不需要重新提交一個新的版本到App store上。

而在What’s New in Xcode-New Features in Xcode 7中,還有一段如下的描述:

Bitcode. When you archive for submission tothe 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 bitexecutables as necessary.

當提交程序到App store上時,Xcode會將程序編譯爲一箇中間表現形式(bitcode)。然後App store會再將這個botcode編譯爲可執行的64位或32位程序。

再看看這兩段描述,都是放在App Thinning(App瘦身)一節中,可以看出其與包的優化有關了。

Bitcode的使用

由上面的說明可以看出,Bitcode包的作用其實就是讓蘋果對我們的編譯代碼進行一次優化。

第三方庫支持就是使用,不支持就選NO

實際上,在Xcode7中,我們新建一個iOS程序時,Bitcode選項是默認設置YES的。我們可以在Build settings —> Enable Bitcode選項中看到設置。

對於iOS,Bitcode是可選的,根據你對APP的要求已經第三方庫的事情情況決定是否使用;對於watchOS,Bitcode是必選的;而Mac OS是不支持Bitcode的。


發佈了42 篇原創文章 · 獲贊 9 · 訪問量 12萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章