2018-09-20 14:08:47.566752+0800 MCDownloaderDemo[15002:1975866] 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.
2018-09-20 14:08:47.566950+0800 MCDownloaderDemo[15002:1975866] Cannot start load of Task <5DCC5F0A-03DD-4186-83F4-10416CDABF06>.<1> since it does not conform to ATS policy
2018-09-20 14:08:47.567246+0800 MCDownloaderDemo[15002:1975865] Task <5DCC5F0A-03DD-4186-83F4-10416CDABF06>.<1> finished with error - code: -1022
2018-09-20 14:08:47.593140+0800 MCDownloaderDemo[15002:1975740] ==Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSUnderlyingError=0x60400044c930 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}, NSErrorFailingURLStringKey=http://dzs.xuanshu.com/txt/16167.txt, NSErrorFailingURLKey=http://dzs.xuanshu.com/txt/16167.txt, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}
以上方法虽然解决了HTTP不能正常使用的问题,但是苹果提供的安全保障也被关闭了,对于不支持HTTPS协议的网站,可以考虑白名单:
也可以通过代码编辑,如下图用代码方式打开info.plist即可。
代码编辑白名单:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>baidu.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>163.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>