iOS9 HTTP 修改 Info.plist 文件后还是不能正常使用


最近在做 iOS9 的网络适配,公司用的 HTTP 协议,因为 iOS9 ATS 导致项目不能正常使用,报错是


 Failed to send request for reason:Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."

显然是 ATS 的问题。但是我修改了 Info.plist 文件之后还是报错,而且报错信息没有变,请问大家有没有遇到的或者有什么解决方案吗?

还有,我是这样修改的 Info.plist 文件:


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

xcode7 https ios9

HeyMoon 8 years, 8 months ago

遇到这类问题,90%是出现在“一个 Project 多 Target ”的情况下,所以
请确保你修改的,确实是你的 Target 所属的 Info.plist !

如何确认?请前往这里,确认你 Target 所属的 Info.plist 究竟是哪个:

Project -> Your Target -> Build Settings -> Info.plist File

enter image description here

或者更直截了当一点,直接修改:

Project -> Your Target —>info-> Custom iOS target properties-> 添加禁用 ATS 的属性

enter image description here

更多 iOS9适配问题请访问--》 《iOS9适配系列教程 》

Treed answered 8 years, 8 months ago

IOS9要求所有接口使用https.错误原因就是这个

hwh125 answered 8 years, 8 months ago

代码没问题,应该是你加错了位置。尝试加到第五行:

pic

有老婆的老婆饼 answered 8 years, 8 months ago

Your Answer