隨着 Xcode7的面世,我們都清楚的知道,他可以不通過https://developer.apple.com中的測試證書就可以真機測試了,對於我們開發者來說這是一個很好地事情,但是也會出現一些問題。
我們在做項目的時候,或多或少的會用的到第三方類庫,那么問題來了,當你用 xcode在真機(iOS 8.3)上運行一下工程,結果發現工程編譯不過。看了下問題,報的是以下錯誤:
ld: ‘/Users/**/Framework/SDKs/PolymerPay/Library/mobStat/lib**SDK.a(**ForSDK.o)’does not contain bitcode. You must rebuild it with bitcode enabled (Xcodesetting ENABLE_BITCODE), obtain an updated library from the vendor, or disablebitcode for this target. for architecture arm64
看警告可以得到的信息是"引入的一個第三方庫不包含bitcode"。 嗯? bitcode 是神馬東西呢?
好吧 我們去查詢一下API 吧,終於找到了
在 Distribution 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位程序。
可到這里,我還是不太明白是神馬意思,通過查閱相關資料,得出的結論是 這個東西應該和包得優化有關。
出現問題,我們要想辦法解決它
在上面的錯誤提示中,提到了如何處理我們遇到的問題:
You must rebuild it with bitcode enabled(Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, ordisable bitcode for this target. for architecture arm64
意思就是說:要不你第三方類庫支持 bitcode 要不你就關掉它
好吧,我們只能選擇后者了
我們來看看他在那里?
新建一個工程,我們可以在”Build Settings”->”Enable Bitcode”選項中看到這個設置。當然我這里是改過的,其實新建的 xcode 工程 bitcode 是默認打開的!
好了改成 NO 就可以真機測試了!要是打包沒有改為 NO 的話.再上傳包的時候是可以看到這個選項的,截圖我就不發了。