iOS 9 适配

参考:http://blog.csdn.net/lvxiangan/article/details/48675881

 

1. 默认使用HTTPS请求

如果在Xcode 9之前使用的时http请求,那么在XCode 9上编译的App是不能联网的,会提示如下错误:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

解决方法:

1.使服务器支持https访问

2.要么关闭https的使用

第一种方法对于个人开发者来说代价还是比较大的,因此推荐使用后面一种方法,具体的做法是:在工程的Info.plist文件里添加NSAppTransportSecurity字典类型的,添加一个元素:key为NSAllowsArbitraryLoads,值为YES。

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

 

2. iOS 9使用URL scheme必须将其加入白名单

会提示类似如下错误:

canOpenURL: failed for URL: "mqqopensdkapiV2://qqapp" - error: "This app is not allowed to query for scheme mqqopensdkapiV2”

解决方法:

Info.plist文件中添加一个key为LSApplicationQueriesSchemes的数组值,里面包含需要添加白名单的string类型的scheme。

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>XXXX schema</string>
</array>

 

3. bitcode

使用Xcode7编译提示:XXX 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配置的程序将会在App store上被编译和链接。bitcode允许苹果在后期重新优化我们程序的二进制文件,而不需要我们重新提交一个新的版本到App store上。

Xcode7 默认开启了bitcode,如果App使用的第三方类库不支持bitcode会提示错误,只需要在”Build Settings”->”Enable Bitcode”选项中看关闭bitcode即可。

开启Bitcode编译后,编译产生的文件体积会变大 (因为是中间代码,不是用户下载的包),且dSYM文件不能用来崩溃日志的符号化 (用户下载的包是Apple服务重新编译产生的,有产生新的符号文件)。通过Archive方式上传AppStore的包,可以在 Xcode的Organizer工具中下载对应安装包的新的符号文件。

4. 使用XCode7链接第三方库提示warning

Lots of warnings when building with Xcode 7 with 3rd party libraries
warning: Could not resolve external type c:objc(cs)NSString
warning: Could not resolve external type c:objc(cs)NSDictionary
warning: Could not resolve external type c:objc(cs)NSMutableString
warning: Could not resolve external type c:objc(cs)NSError
https://forums.developer.apple.com/thread/17921
目前没发现好的解决办法,可以尝试如下:
I had this problem too. Here's how I fixed it.
1) Go to Build Settings -> Build Options -> Debug Information Format
2) Change the Debug setting from "DWARF with dSYM File" to "DWARF"
3) Leave the Release setting at "DWARF with dSYM File"
The problem appears to be that Xcode was trying to create dSYM files for Debug builds. You don't need dSYM files for Debug builds -- it's release builds where you need them.

posted @ 2015-09-24 12:25  mobilefeng  阅读(1033)  评论(0编辑  收藏  举报