原文网址: http://www.cocoachina.com/ios/20150818/13078.html

今天试着用Xcode 7 beta 3在真机(iOS 8.3)上运行一下我们的工程,结果发现工程编译不过。看了下问题,报的是以下错误:

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是啥,所以就得先看看这货是啥了。

Bitcode是什么?

找东西嘛,最先想到的当然是先看官方文档了。在App Distribution Guide – App Thinning (iOS, watchOS)一节中,找到了下面这样一个定义:

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上。

嗯,看着挺高级的啊。

继续看,在What’s New in Xcode-New Features in Xcode 7中,还有一段如下的描述

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.

当我们提交程序到App store上时,Xcode会将程序编译为一个中间表现形式(bitcode)。然后App store会再将这个botcode编译为可执行的64位或32位程序。

再看看这两段描述都是放在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

参考

 

最新文章

  1. COALESCE NVL NVL2 DECODE
  2. swift皮筋弹动发射飞机
  3. IBM开发者 JSON 教程
  4. 430单片机之定时器A功能的大致介绍
  5. [Whole Web, Nods.js, PM2] Passing environment variables to node.js using pm2
  6. android通用文件操作
  7. javaWeb中一个按钮提交两个表单
  8. mvn 使用中的错误
  9. BottomSheetBehavior 之 java.lang.IllegalArgumentException: The view is not associated with BottomSheetBehavior
  10. 客户端浏览器判断(ios .android)
  11. 基于Metronic的Bootstrap开发框架经验总结(17)-- 使用 summernote插件实现HTML文档的编辑和图片插入操作
  12. java LinkedLis t的26种使用方法
  13. Hibernate HQL中的子查询
  14. 使用 WTForms 进行表单验证的例子
  15. 【Qt编程】基于Qt的词典开发系列<二>--本地词典的设计
  16. sql注入-推断是否存在SQL注入-单引号
  17. Machine learning | 机器学习中的范数正则化
  18. PHP中cURL的应用
  19. Android 简单天气预报
  20. ABAP非Unicode系统中字符串拼接(CONCATENATE)时吃字符问题

热门文章

  1. 关于js开发的小问题
  2. Java类加载器( 死磕9)
  3. tornado之模板扩展
  4. 7.JavaScript变量
  5. ZOJ - 3956 Course Selection System 【01背包变形】
  6. 【bzoj2809】dispatching
  7. 从数据的角度带你深入了解IPFS
  8. elasticsearch 中文分词(elasticsearch-analysis-ik)安装
  9. BZOJ1566 【NOI2009】管道取珠
  10. js事件传播的一个疑惑