ios 9和NSAppTransportSecurity [英] ios 9 and NSAppTransportSecurity

查看:217
本文介绍了ios 9和NSAppTransportSecurity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS 9存在问题并与服务器配合使用。
我在info.plist设置:

There is a problem with iOS 9 and work with the server. I info.plist set:

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

当你通过Xcode运行应用程序时,一切都很好。完美地使用服务器。但是只要我停止应用程序并尝试通过单击模拟器中的图标来运行它。网络停止工作。我将应用程序发送到TestFlight中的Review时出现同样的问题。应用程序已安装,但网络再次停止工作。

When you run the application through Xcode, everything is fine. Work with the server takes place perfectly. But as soon as I stop the application and try to run it by simply clicking on the icon in the simulator. The network stops working. The same problem when I send the application to the Review in TestFlight. The application is installed, but the network stops working again.

Xcode 7.0(7a220)
iOS 9.0

Xcode 7.0 (7a220) iOS 9.0

推荐答案

你确定它不起作用吗?我测试过,一切都很好。

Are you sure it's not working? I tested it and everything is fine.

可能的行动

拥有启用调试模式,构建您的应用程序,从Xcode运行它并确保您获得 App Transport Security 错误:

Having a Debug mode enabled, build your app, run it from Xcode and make sure that you don't get an App Transport Security error:

App Transport Security已阻止明文HTTP(http://)资源加载,因为它不安全。

使用模拟器从Xcode启动时。现在找到同样非常模拟器的 DEVICE_CODE

when launching it from Xcode using your simulator. Now find a DEVICE_CODE of the same very simulator

(提示:它将是其中一个〜/ Library / Developer / CoreSimulator / Devices /。从Xcode中找到此代码的最简单方法是使用Window-> Devices)

并打开控制台其日志文件:

~/Library/Logs/CoreSimulator/<DEVICE_CODE>/system.log

清除历史记录(以防您再次从Xcode启动应用程序并确保您的输出进入您打开的日志文件,并且您仍然没有 App Transport Security 错误。)

Clear the history (just in case you can launch your app from Xcode once again and make sure your output is getting into the log-file you opened, and that you still don't get App Transport Security error in there).

现在从模拟器启动您的应用程序,并检查日志中是否有与 App Transport Security 相关的任何错误。

Now launch your app from the simulator and check if you have any errors related to App Transport Security in the log.

对我来说,如果从Xcode工作,我没有任何东西。

For me I don't have any if none of them I get when working from Xcode.

= =================================

==================================

PS

强烈建议不要将 NSAllowsArbitraryLoads 设置为 true ,你要我希望通过以下方式获得理想的结果:

It's strongly recommended to not set an NSAllowsArbitraryLoads to true, you'd rather want to achieve the desired result with:

<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>

这篇关于ios 9和NSAppTransportSecurity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆