Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to monitor network calls made from iOS Simulator

People also ask

How do I see network calls in Xcode?

From Xcode's Product menu, choose Profile. After Instruments launches, select the Network template, then click Choose. The Network Connections and HTTP Traffic instruments appear in a new window, along with the timeline and detail panes.

How do I monitor network traffic on my iPhone?

Now go to your iOS device: Select Settings > Wi-Fi > your Wi-Fi network. Click the blue 'i' button to show more details of the network.

Where does the iPhone simulator store its data?

type: ~/Library/Application Support/iPhone Simulator.


Personally, I use Charles for that kind of stuff.
When enabled, it will monitor every network request, displaying extended request details, including support for SSL and various request/reponse format, like JSON, etc...

You can also configure it to sniff only requests to specific servers, not the whole traffic.

It's commercial software, but there is a trial, and IMHO it's definitively a great tool.


A man-in-the-middle proxy, like suggested by other answers, is a good solution if you only want to see HTTP/HTTPS traffic. Burp Suite is pretty good. It may be a pain to configure though. I'm not sure how you would convince the simulator to talk to it. You might have to set the proxy on your local Mac to your instance of a proxy server in order for it to intercept, since the simulator will make use of your local Mac's environment.

The best solution for packet sniffing (though it only works for actual iOS devices, not the simulator) I've found is to use rvictl. This blog post has a nice writeup. Basically you do:

rvictl -s <iphone-uid-from-xcode-organizer>

Then you sniff the interface it creates with with Wireshark (or your favorite tool), and when you're done shut down the interface with:

rvictl -x <iphone-uid-from-xcode-organizer>

This is nice because if you want to packet sniff the simulator, you're having to wade through traffic to your local Mac as well, but rvictl creates a virtual interface that just shows you the traffic from the iOS device you've plugged into your USB port.


Recently i found a git repo that makes it easy.

You can try it.

This is an app's screenshot: enter image description here

Best regards.


A free and open source proxy tool that runs easily on a Mac is mitmproxy.

The website includes links to a Mac binary, as well as the source code on Github.

The docs contain a very helpful intro to loading a cert into your test device to view HTTPS traffic.

Not quite as GUI-tastic as Charles, but it does everything I need and its free and maintained. Good stuff, and pretty straightforward if you've used some command line tools before.

UPDATE: I just noticed on the website that mitmproxy is available as a homebrew install. Couldn't be easier.


Xcode provides CFNetwork Diagnostic Logging. Apple doc

To enable it, add CFNETWORK_DIAGNOSTICS=3 in the Environment Variable section:

enter image description here

This will show requests from the App with its headers & body. Note that OS_ACTIVITY_MODE must be set to enable as shown. Otherwise no output will be shown on the Console.


Wireshark it

Select your interface

enter image description here

Add filter start the capture

enter image description here


Testing

Click on any action or button that would trigger a GET/POST/PUT/DELETE request

You will see it on listed in the wireshark

enter image description here

If you want to know more details about one specific packet, just select it and Follow > HTTP Stream.

enter image description here

hope this help others !!


It seems this may have recently been added. Clicking command + control + z on the simulator will pop up a debug menu. From that menu, click Inspect. Inspect will present tabs. Click the network tab and that will show all network requests being made.