iOS開發——打包報錯error: linker command failed with exit code 1


  真機運行沒問題,打包報錯:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

  

  原因:在Xcode 7中,我們新建一個iOS程序時,bitcode選項默認是設置為YES的。我們可以在”Build Settings”->”Enable Bitcode”選項中看到這個設置。不過,我們現在需要考慮的是三個平台:iOS,Mac OS,watchOS。對於iOS,bitcode是可選的;對於watchOS,bitcode是必須的;而Mac OS是不支持bitcode。所以,如果我們的工程需要支持bitcode,則必要要求所有引入的第三方庫都支持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配置的程序將會在App store上被編譯和鏈接。bitcode允許蘋果在后期重新優化程序的二進制文件,而不需要重新提交一個新的版本到App store上。

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


解決方案

  Build Settings中,把Enable Bitcode設置為NO


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM