iOS9出来一周多了,里面那个返回功能我是爱极了,但是作为程序员,iOS9带来的烦恼也是极多。网上的大神已经总结不少干货了,我就不在赘述了,仅仅自己这段时间遇到的问题做个总结(当然好多方法其实也是借鉴大神提供的,如果关系到侵权的问题,还请第一时间联系我),也和大家分享一下,要是能给你带来些许帮助,幸运至极。(此篇会根据实际情况不限时更新)
第一个问题:iOS9网络适配_改用更安全的HTTPS
官方文档的原文是:
App Transport Security (ATS) enforces best practices in the secure connections between an app and its back end. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt; it is also on by default in iOS 9 and OS X v10.11. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.
If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible. In addition, your communication through higher-level APIs needs to be encrypted using TLS version 1.2 with forward secrecy. If you try to make a connection that doesn't follow this requirement, an error is thrown. If your app needs to make a request to an insecure domain, you have to specify this domain in your app's Info.plist
file.
大意是:ATS加强app和服务器的安全联系,防止不经意的泄露,并在iOS9和OS X v10.11中是默认的,不管是是开发一个新的app还是更新一个旧的,都应该尽快适应ATS。如果你开发新的app,必须使用https请求,如果是已经有的app,也应该尽量多的使用https,并且制定一个计划尽快的把剩下的非https(如HTTP)改成https。另外为了更好的保密,网络请求使用TLS1.2版本。
目前两个解决办法:1、把所有的HTTP请求换成https请求(这短时间内成本太高)
2、在info.plist的源文件里加入如下代码:(参考App Transport Security Technote https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/)
<key>NSAppTransportSecurity</key>
<dict>
<!--Connect to anything (this is probably BAD)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
第二个问题:Bitcode(通俗解释:在线版安卓ART模式)
把Xcode升级7.0之后运行代码出现以下警告:
(null): URGENT: all bitcode will be dropped because '/Users/myname/Library/Mobile Documents/com~apple~CloudDocs/foldername/appname/GoogleMobileAds.framework/GoogleMobileAds(GADSlot+AdEvents.o)' was built without 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. Note: This will
be an error in the future. 这是因为Xcode7中默认开启了Bitcode,还好iOS目前不强求。
两个解决方案:1、更新library使包含Bitcode(长远来说推荐这个,但是短时间内特别麻烦)。
2、在Build Settings里搜索bitcode,然后把enanble bitcode 右侧的yes改成no即可(是不是很方便哦)
第三个问题:关于info.plist 第三方登录 添加URL Schemes白名单
升级iOS9和Xcode7之后发现微信、朋友圈、QQ和QQ空间分享不管怎么弄老是提醒没有安装,撞了鬼了是不?我也觉得,后来发现是iOS 9系统策略更新,限制了http协议的访问,此外应用需要在“Info.plist”中将要使用的URL Schemes列为白名单,才可正常检查其他应用是否安装。
解决办法:在info.plist的源文件里添加如下代码:(这里包含新浪微博、微信、QQ和支付宝)<key>LSApplicationQueriesSchemes</key>
<array>
<!-- 微信 URL Scheme 白名单-->
<string>wechat</string>
<string>weixin</string>
<!-- 新浪微博 URL Scheme 白名单-->
<string>sinaweibohd</string>
<string>sinaweibo</string>
<string>sinaweibosso</string>
<string>weibosdk</string>
<string>weibosdk2.5</string>
<!-- QQ、Qzone URL Scheme 白名单-->
<string>mqqapi</string>
<string>mqq</string>
<string>mqqOpensdkSSoLogin</string>
<string>mqqconnect</string>
<string>mqqopensdkdataline</string>
<string>mqqopensdkgrouptribeshare</string>
<string>mqqopensdkfriend</string>
<string>mqqopensdkapi</string>
<string>mqqopensdkapiV2</string>
<string>mqqopensdkapiV3</string>
<string>mqzoneopensdk</string>
<string>wtloginmqq</string>
<string>wtloginmqq2</string>
<string>mqqwpa</string>
<string>mqzone</string>
<string>mqzonev2</string>
<string>mqzoneshare</string>
<string>wtloginqzone</string>
<string>mqzonewx</string>
<string>mqzoneopensdkapiV2</string>
<string>mqzoneopensdkapi19</string>
<string>mqzoneopensdkapi</string>
<string>mqzoneopensdk</string>
<!-- 支付宝 URL Scheme 白名单-->
<string>alipay</string>
<string>alipayshare</string>
</array>
第四个问题:富文本OHAttributedLabel
升级之后莫名其妙的发现一些文字不显示了,经检查发现是这个家伙的原因,经试验找到了一下办法:
把OHAttributedLabel全部用它的父类UILabel替换即可(是不是很无语?我也觉得很无语,如果你有更好的办法请千万要及时告诉我哦,不过我觉得自从iOS6之后这个家伙好像就有点鸡肋了~~)
今天先写到这里,其他还有一些诸如静态库的后缀都由dylib改成tbd、App Thinning等问题如果还未遇到,但是肯定会遇到,而且应该会很快,估计应该会有新的好的总结方法出来。
粗糙之作,欢迎指教!