xcode 用iOS模拟器调试网络请求,网络请求数据不显示

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29436895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:05:15  来源:igfitidea点击:

Debugging network requests with iOS Simulator, network request data is not showing

xcodemacossafarisimulator

提问by Berlin Brown

I am trying to debug the network requests for a hybrid/webview cordova based application in the ios simulator, actually see the network requests in the Safari Web Inspector. I am trying to use the Web Inspector within Safari to monitor the network requests to the server but all I see is the "timeline" graph, I don't see the actual URI requests. Is there a way to enable this?

我正在尝试在 ios 模拟器中调试基于混合/webviewcordova 的应用程序的网络请求,实际上在 Safari Web Inspector 中查看网络请求。我正在尝试使用 Safari 中的 Web Inspector 来监视对服务器的网络请求,但我看到的只是“时间线”图,我没有看到实际的 URI 请求。有没有办法启用它?

I build my application through xcode. Launch the iOS simulator with iPad2 selected/iOS 8.1. I then launch Safari and select the "ios simulator/index.html" to launch the web inspector. And then click on network requests. The resources tab pane is empty when I make web request calls. Is there a way to fix this so I can see the url requests?

我通过 xcode 构建我的应用程序。选择 iPad2/iOS 8.1 启动 iOS 模拟器。然后我启动 Safari 并选择“ios模拟器/index.html”来启动网络检查器。然后点击网络请求。当我进行 Web 请求调用时,资源选项卡窗格为空。有没有办法解决这个问题,以便我可以看到 url 请求?

  • Xcode: 6.1.1
  • Safari: 7.1.3
  • OSX: 10.9.5
  • 代码:6.1.1
  • Safari:7.1.3
  • OSX:10.9.5

采纳答案by Mojtaba

I'm not quite sure if it's even possible to do that via web inspector or not but put option 1 just in case. I highly recommend you to go with Option 2 tho.

我不太确定是否可以通过网络检查器来做到这一点,但为了以防万一,请选择选项 1。我强烈建议您使用选项 2。

Option 1

选项1

First make sure you don't have anything filtered, then make sure recording is on as shown in picture.

首先确保您没有过滤任何内容,然后确保录制已打开,如图所示。

Steps to verify inspector is working

验证检查员工作的步骤

Option 2. RECOMMNDED

选项 2. 推荐

Use an http monitoring tool. They are design to do that specific task plus you get many more options such as breakpoints, etc.

使用 http 监控工具。它们旨在完成该特定任务,并且您可以获得更多选项,例如断点等。

  • Charles Proxy. (MAC) The best IMHO. You can set breakpoints and alter request/response if needed. And many other features.
  • HttpScoop(MAC) Easier to use, but less functionality.
  • fiddler(WINDOWS) Just in case.
  • 查尔斯代理。(MAC)最好的恕我直言。如果需要,您可以设置断点并更改请求/响应。以及许多其他功能。
  • HttpScoop(MAC) 更易于使用,但功能较少。
  • 提琴手(WINDOWS)以防万一。

PS. Some one might say Wireshark, I know but it's too complicated for such work.

附注。有人可能会说Wireshark,我知道但对于这样的工作来说太复杂了。

[UPDATE 1]To make it clear you don't need to set any proxy on iOS simulator to get these tools working. In case of SSL connections you want to use charles and follow their SSL guideline.

[更新 1]明确地说,您无需在 iOS 模拟器上设置任何代理即可使这些工具正常工作。在 SSL 连接的情况下,您希望使用 charles 并遵循他们的SSL 指南