xcode 如何在 iOS 上的 React Native 应用程序上检查网络流量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35045750/
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
How do I inspect network traffic on a react native app on iOS?
提问by DLeonardi
I'm using the latest React Native (0.18 at the time of this writing) and would like to inspect the network requests my iOS simulator makes.
Using the latest Xcode "instruments" i get this: . I get the same error on both 10.11 and 10.10 machines, both using the latest Xcode.
我正在使用最新的 React Native(在撰写本文时为 0.18)并且想检查我的 iOS 模拟器发出的网络请求。采用最新的Xcode“乐器”我得到这个:。我在 10.11 和 10.10 机器上都遇到了相同的错误,两者都使用最新的 Xcode。
I've also tried using Charles, but it's unable to intercept the traffic. Wireshark is able to see it, but the data I'm after is SSL based, so I cannot access it.
我也尝试过使用 Charles,但它无法拦截流量。Wireshark 能够看到它,但我所追求的数据是基于 SSL 的,所以我无法访问它。
As a webdeveloper, ideally I'd like to inspect network traffic in my chrome debugger, but I understand that this cannot be possible in this kind of environment, but simply looking at raw packet data is not userfriendly enough for debugging purposes.
作为一名 web 开发人员,理想情况下我想在我的 chrome 调试器中检查网络流量,但我知道这在这种环境中是不可能的,但是仅仅查看原始数据包数据对于调试目的来说不够用户友好。
Who knows of a solution for this?
谁知道这个问题的解决方案?
采纳答案by DLeonardi
Turns out using Charles is a good option.
事实证明,使用 Charles 是一个不错的选择。
Just set up the SSL certificates: Help > SSL Proxying > Install Charles Root Certificate in iOS Simulators) in charles and be happy!
只需在 charles 中设置 SSL 证书:帮助 > SSL 代理 > 在 iOS 模拟器中安装 Charles Root 证书),然后开心!
回答by kmdupr33
Actually, now you can view network traffic using the react native network inspector introduced in version 0.33. I demo how to use the inspector in my video on how to make network requests in react native (starting at 1:46) http://codecookbook.co/post/how-to-make-network-requests-in-react-native/
实际上,现在您可以使用版本 0.33 中引入的 react native network inspector 查看网络流量。我演示了如何在我的视频中使用检查器,了解如何在 React Native 中发出网络请求(从 1:46 开始)http://codecookbook.co/post/how-to-make-network-requests-in-react-本国的/
回答by Fahad Rehman
I might be a little bit late but as I was searching on this topic I found this https://github.com/infinitered/reactotrontool very helpful, this not only displays the network traffic but also displays the errors in the application and state also
我可能有点晚了,但是当我搜索这个主题时,我发现这个https://github.com/infinitered/reactotron工具非常有用,它不仅显示网络流量,还显示应用程序和状态中的错误还