今天升级Xcode 7.0 bata发现网络访问失败。
输出错误信息
<code style="padding: 0px; color: inherit; white-space: inherit; background-color: transparent;"><span style="font-family:Comic Sans MS;font-size:18px;">The resource could not be loaded because the App Transport Security policy requires the <span class="hljs-operator"><span class="hljs-keyword" style="color: rgb(133, 153, 0);">use</span> <span class="hljs-keyword" style="color: rgb(133, 153, 0);">of</span> a secure <span class="hljs-keyword" style="color: rgb(133, 153, 0);">connection</span>.
</span></span></code>
Google后查证,iOS9引入了新特性App Transport Security (ATS)。详情:App Transport Security (ATS)
新特性要求App内访问的网络必须使用HTTPS协议。
但是现在公司的项目使用的是HTTP协议,使用私有加密方式保证数据安全。现在也不能马上改成HTTPS协议传输。
最终找到以下解决办法:
- 在Info.plist中添加
NSAppTransportSecurity类型Dictionary。 - 在
NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES
本文介绍在Xcode7.0beta版中遇到的网络访问失败问题及解决方法。由于App Transport Security(ATS)政策变更,需将项目的网络连接方式从HTTP改为HTTPS。文中提供了在Info.plist文件中配置NSAppTransportSecurity来解决此问题的具体步骤。
1397

被折叠的 条评论
为什么被折叠?



