iOS 9出现问题,无法与服务器配合使用。I info.plist set:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>当您通过Xcode运行应用程序时,一切都很正常。与服务器的工作可以完美地进行。但只要我停止应用程序并尝试通过简单地单击模拟器中的图标来运行它。网络停止工作。当我在TestFlight中将应用程序发送到审阅时,也会遇到同样的问题。应用程序已安装,但网络再次停止工作。
Xcode 7.0 (7a220) iOS 9.0
发布于 2015-09-19 20:06:13
你确定它不工作了吗?我测试过了,一切都很好。
可能的操作
启用Debug模式,构建您的应用程序,从Xcode运行它,并确保您不会收到app Transport Security错误:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure.
当使用模拟器从Xcode启动它时。现在找到同一个模拟器的DEVICE_CODE
(Hint: it will be one of these ~/Library/Developer/CoreSimulator/Devices/. The easiest way to find this code from Xcode is to go Window->Devices)
并使用Console打开其日志文件:
~/Library/Logs/CoreSimulator/<DEVICE_CODE>/system.log清除历史记录(以防你可以再次从Xcode启动你的应用程序,并确保你的输出进入了你打开的日志文件中,并且你仍然不会在那里得到app Transport Security错误)。
现在从模拟器启动您的应用程序,并检查日志中是否有任何与app Transport Security相关的错误。
对于我来说,如果我在Xcode中工作时没有得到任何一个,我也没有。
==================================
P.S.
强烈建议不要将NSAllowsArbitraryLoads设置为true,您更希望使用以下命令来达到预期效果:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>发布于 2015-10-01 18:40:08
应该这样做,您需要在Plist中添加以下记录Apple Documentation
它很懒惰,所以您的框架可以访问Internet
NSAppTransportSecurity <-类型字典
NSAllowsArbitraryLoads <-类型布尔值是

发布于 2016-07-21 16:36:28
这很简单,只需遵循以下步骤:

注意:发生此问题是因为默认情况下,您的项目设置不允许任何跨站点脚本引用。因此,它会阻止应用程序之外的任何服务调用。
https://stackoverflow.com/questions/32663122
复制相似问题