Bitcode簡介
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.
蘋果官方對Bitcode的評價描述是,Bitcode是被編譯程序的一種中間形式的代碼。包含Bitcode配置的程序?qū)贏pp store上被編譯和鏈接。目的是為了減少App的安裝包大小,使用戶不必下載不適合自己系統(tǒng)的那部分資源
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.
當(dāng)我們提交程序到App store上時,Xcode會將程序編譯為一個中間表現(xiàn)形式(Bitcode)。然后App store會再將這個Bitcode編譯為可執(zhí)行的64位或32位程序。
Bitcode配置
在實(shí)際開發(fā)中,需要考慮的是三個平臺:iOS,Mac OS,watchOS。
- 對應(yīng)iOS,Bitcode是可選的。
- 對于watchOS,Bitcode是必須的。
- Mac OS不支持Bitcode。
方法一:更新library使包含Bitcode,否則會出現(xiàn)以下中的警告;
(null): URGENT: all bitcode will be dropped because '/Users/myname/Library/Mobile Documents/com~apple~CloudDocs/foldername/appname/GoogleMobileAds.framework/GoogleMobileAds(GADSlot+AdEvents.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.
方法二:關(guān)閉Bitcode,在”Build Settings”->”Enable Bitcode”選項(xiàng)中看到這個設(shè)置。