关于Bitcode的一点见识

来源:互联网 发布:苹果软件计划 编辑:程序博客网 时间:2024/05/01 01:42

      今天在给项目配置发布证书的时候,遇到一个非常有意思的问题,没有发布证书的时候,模拟器上面跑没有任何问题。但是在配置好发布证书,再次运行的时候却出现了如下问题:

在查找资料之后确定是:第三方库不包含bitcode就会报错,所以就查找了相关Bitcode的资料,下面来了解一下Bitcode。

一、Bitcode是什么?

      1. 在官方文档的  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上。

    2.在 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瘦身)一节中,这就不难看出它其与包的优化有关了。

二、Bitcode配置

      下面介绍如何处理我们上面遇到的问题:


      方法:1、让第三方库支持,2、关闭target的bitcode选项。


       在Xcode 7后,我们新建一个iOS程序时,bitcode选项默认是设置为YES的。可以在”Build Settings”->”Enable Bitcode”选项中看到这个设置。但是我们需要考虑的是三个平台:iOS,Mac OS,watchOS。对于iOS,bitcode是可选的;对于watchOS,bitcode是必须的;而Mac OS是不支持bitcode。

        所以,如果我们的工程需要支持bitcode,则必要要求所有引入的第三方库都支持bitcode。

0 0
原创粉丝点击