Xcode7 網絡請求報錯:The resource could not be loaded be

升級Xcode 7.0發現網絡訪問失敗。
輸出錯誤信息html

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.


Google後查證,iOS9引入了新特性App Transport Security (ATS)。詳情:App Transport Security (ATS)ios

新特性要求App內訪問的網絡必須使用HTTPS協議。
可是如今公司的項目使用的是HTTP協議,使用私有加密方式保證數據安全。如今也不能立刻改爲HTTPS協議傳輸。安全

最終找到如下解決辦法:

  1. 在Info.plist中添加NSAppTransportSecurity類型Dictionary網絡

  2. NSAppTransportSecurity下添加NSAllowsArbitraryLoads類型Boolean,值設爲YESapp

其餘問題參考: http://blog.csdn.net/hongfengkt/article/details/48543091ui

相關文章
相關標籤/搜索