IOS9.0升级后以及xcode7后引起的问题

来源:互联网 发布:js的math方法 编辑:程序博客网 时间:2024/04/28 01:03

最近xcode真机调试遇到了编译失败问题:

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't open file: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/usr/lib/libxml2.dylib (No such file or directory)

解决方法:

1、修改bitcode为no(子工程可不改)

2、删除子工程下面target---build phases---link binary with libraries---删除libxml2.dylib



一、iOS9 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位程序。
从中我们可以看出其与包的优化有关了。

现在最大的问题就是xcode7,xcode7默认是打开bitcode的,我们的工程如果采用了别人封装的第三方库,那么好了,就会出现类似以下的错误
ld: ‘///某某第三方库’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。这时候如果要解决编译不通过的问题,要么让第三方库支持,要么关闭target的bitcode选项。

在Xcode 7中,我们新建一个iOS程序时,bitcode选项默认是设置为YES的。我们可以在”Build Settings”->”Enable Bitcode”选项中看到这个设置。将其设置为NO就行了。现在苹果给出的临时解决方案就好比当初MRC和ARC时候的解决办法,当初xcode5更新时候默认是工程创建是ARC的,你可以关闭ARC改为MRC,经过了一段时间后,大家都开始使用了ARC,那么bitcode也一样。

不过,我们现在需要考虑的是三个平台:iOS,Mac OS,watchOS。

对于iOS,bitcode是可选的;对于watchOS,bitcode是必须的;而Mac OS是不支持bitcode。


如果我们开启了bitcode,在提交包时,下面这个界面也会有个bitcode选项:

技术分享

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

二、 iOS9 HTTP 不能正常使用的解决办法
iOS9把所有的http请求都改为https了:iOS9系统发送的网络请求将统一使用TLS 1.2 SSL。采用TLS 1.2 协议,目的是 强制增强数据访问安全,而且 系统 Foundation 框架下的相关网络请求,将不再默认使用 Http 等不安全的网络协议,而默认采用 TLS 1.2。服务器因此需要更新,以解析相关数据。如不更新,可通过在 Info.plist 中声明,倒退回不安全的网络请求。
解决的方法可以在Info.plist中添加NSAppTransportSecurity类型Dictionary。 在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES

三、iOS 9 使用URL scheme必须将其加入白名单
ios9需要将要使用的URL Schemes设置为白名单:如微信支付宝等,需要在plist文件中添加如下代码

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>alipay</string>
        <string>wechat</string>
        <string>weixin</string>
    </array>
四、iOS 9 使用URL scheme必须将其加入白名单

ios9 中.dylib后缀的库更改为.tbd

0 0
原创粉丝点击