Xcode 7提示App Transport Security has blocked a cleartext HTTP (http://) resource load的解决办法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Xcode 7提示App Transport Security has blocked a cleartext HTTP (http://) resource load的解决办法相关的知识,希望对你有一定的参考价值。

 

Xcode 7提示App Transport Security has blocked a cleartext HTTP (http://) resource load的解决办法

 
今天使用Xcode 7打开用Xcode 6开发的网络请求项目,Xcode 7 控制台提示如下: App TransportSecurity has blocked a cleartext HTTP (http://) resource load since it isinsecure. Temporary exceptions can be configured via your app‘s Info.plist file.

 

简而言之:ATS禁止了HTTP的明文传输,因为它不安全。可以修改Info.plist文件,让它临时允许明文传输。

 

解决办法:
在Info.plist文件中添加主Key值"NSAppTransportSecurity", Type为"Dictionary",

再添加次Key值"NSAllowsArbitraryLoads", Type 为"Boolean",“Value”为“YES”即可。

 

在info.plist中添加代码实现为

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

 

修改info.plist文件中可视化操作:

技术分享

以上是关于Xcode 7提示App Transport Security has blocked a cleartext HTTP (http://) resource load的解决办法的主要内容,如果未能解决你的问题,请参考以下文章

iOS开发-Xcode 7 App Transport Security has blocked a cleartext HTTP 报错解决办法

Xcode7 beta 网络请求报错:The resource could not be loaded because the App Transport Security policy requir

The resource could not be loaded because the App Transport

iOS 9使用HTTP(App Transport Security问题)

无法使用 Xcode 7.1 上传到 App Store

关于iOS9中的App Transport Security相关说明及适配(更新于2016.7.1)