iOS中Bitcode的介绍及配置
2015-09-17 13:31
435 查看
今天在一个iOS培训网站上看到一篇关于第三方库不包含bitcode就会报错的文章,感觉剖析得很详细,分享出来,希望可以对iOS初入门者有所帮助。下面我们就一起来看看吧。
用Xcode 7 beta 3在真机(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是个什么鬼?
查阅了一下官方文档,在App
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位程序。
再看看这两段描述,都是放在App Thinning(App瘦身)一节中,可以看出其与包的优化有关了。
Bitcode配置
在上面的错误提示中,提到了如何处理我们遇到的问题:
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
要么让第三方库支持,要么关闭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。
通过本文对bitcode的概念及配置情况的简要介绍,希望iOS开发人员在工程运行中遇到类似的情况,可以根据上文的介绍更有效的找到原因并及时处理。
用Xcode 7 beta 3在真机(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是个什么鬼?
查阅了一下官方文档,在App
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位程序。
再看看这两段描述,都是放在App Thinning(App瘦身)一节中,可以看出其与包的优化有关了。
Bitcode配置
在上面的错误提示中,提到了如何处理我们遇到的问题:
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
要么让第三方库支持,要么关闭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。
通过本文对bitcode的概念及配置情况的简要介绍,希望iOS开发人员在工程运行中遇到类似的情况,可以根据上文的介绍更有效的找到原因并及时处理。
相关文章推荐
- ios 调用系统相册、相机 显示中文标题
- iOS激情详解之URL同步,异步连接
- IOS 取消表格单元格 TableViewCell 去掉高亮状态 点击Cell取消选择状态
- 1、BIOS中的虚拟化技术
- IOS-TextField知多少
- iOS 支付宝 的学习总结
- iOS9AdaptationTips
- iOS开发 iOS9适配问题
- ffmpeg在iOS的使用 - iFrameExtractor源码解析
- iOS 警告收录及科学快速的消除方法
- iOS 集成银联支付(绕过文档的坑,快速集成)
- iOS工程集成支付宝错误symbol(s) not found for architecture x86_64
- 我的第一篇博客
- Xcode7 更新后三方框架丢失。项目报错解决方法
- IOS第一天-新浪微博 - 框架的搭建
- iOS工程集成支付宝错误Undefined symbols for architecture armv7
- iOS 9 适配系列教程
- IOS开发之----property详解
- ios各种动画效果
- IOS 调用摄像头拍照