天天看點

iOS9 HTTP 不能正常使用的解決辦法 文iOS9 HTTP 不能正常使用的解決辦法 最終找到以下解決辦法: 看到很多同學修改後還是不能用添加一下截圖:

文iOS9 HTTP 不能正常使用的解決辦法

  • ios 
  • xcode

isteven 2015年06月25日釋出

  • 推薦 3 推薦
  • 收藏 39 收藏,72.5k 浏覽

今天更新

Xcode 7.0 bata

發現網絡通路失敗。

輸出錯誤資訊

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)

新特性要求App内通路的網絡必須使用

HTTPS

協定。

但是現在公司的項目使用的是

HTTP

協定,使用私有加密方式保證資料安全。現在也不能馬上改成

HTTPS

協定傳輸。

最終找到以下解決辦法:

  1. 在Info.plist中添加

    NSAppTransportSecurity

    類型

    Dictionary

  2. NSAppTransportSecurity

    下添加

    NSAllowsArbitraryLoads

    類型

    Boolean

    ,值設為

    YES

看到很多同學修改後還是不能用添加一下截圖:

  1. 在Filter中搜尋

    Info.plist

    ,選擇

    Info.plist

    進行編輯
    iOS9 HTTP 不能正常使用的解決辦法 文iOS9 HTTP 不能正常使用的解決辦法 最終找到以下解決辦法: 看到很多同學修改後還是不能用添加一下截圖:
  2. 按照上面提到的方式添加資訊,正确的修改會看到下圖這個樣子,注意類型

    NSAppTransportSecurity

    Dictionary

    NSAllowsArbitraryLoads

    Boolean

    ,複制粘貼的時候,不要多了空格,segment fault 頁面上直接複制,經常會多一個出空格!
    iOS9 HTTP 不能正常使用的解決辦法 文iOS9 HTTP 不能正常使用的解決辦法 最終找到以下解決辦法: 看到很多同學修改後還是不能用添加一下截圖:
  3. 注意⚠️,單元測試下面也有一個

    Info.plist

    ,修改那個檔案是沒有作用的!

    NSAppTransportSecurity->(App Transport Security Settings)

繼續閱讀