[xcode] How to monitor network calls made from iOS Simulator

I am trying to monitor calls from an app to my server just like Firebug does. I could not find a way to see that in iOS Simulator or in xCode.

Is there a way to do that without sniffing all the traffic? If no, what tool would you suggest?

This question is related to xcode networking ios-simulator network-monitoring

The answer is


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.


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.


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


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.


If you have cable connection and Mac, then there is simple and powerful method:

  1. install free Wireshark, make sure that it can capture devices with (and you need to do this after every computer restart!):

    sudo chmod 644 /dev/bpf*

  2. Now share your network with wifi. System preferences > Sharing > Internet Sharing. Check that you have "Share your connections from: Ethernet" and using: Wi-Fi. You may want to also to configure some wifi security, it does not disturb your data monitoring.

  3. Connect your phone to your newly created network. I need quite often several attempts here. If the phone does not want to connect, turn of wifi of Mac, then repeat step 2 above and be patient.

  4. Start Wireshark capture your wireless interface with Wireshark, it is probably "en1". Filter your needed IP addresses and/or ports. When you find a package which is interesting, select it, Right-click (context menu) > Follow TCP Stream and you see nice text representation of the requests and answers.

And what is the best: exactly the same trick works for Android also!


I use netfox. It is very easy to use and integrate. You can use it on simulator and device. It shows all of the requests and responses. It supports JSON, XML, HTML, Image and Other types of responses. You can share requests, responses and full log by IOS default sharing formats (Gmail, WhatsApp, email, slack, sms, etc.)

You can check on GitHub: https://github.com/kasketis/netfox

Netfox provides a quick look on all executed network requests performed by your iOS or OSX app. It grabs all requests - of course yours, requests from 3rd party libraries (such as AFNetworking, Alamofire or else), UIWebViews, and more


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.



A good solution if you are used to the chrome inspector tools is Pony debugger: https://github.com/square/PonyDebugger

It is a bit of a pain to setup, but once you do it work well. Be sure to use Safari instead of Chrome to use it though.


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.


  1. Install WireShark
  2. get ip address from xcode network monitor
  3. listen to wifi interface
  4. set filter ip.addr == 192.168.1.122 in WireShark

You can also use this open source library called Wormholy (and made by me).

You just need to integrate it in your project (no code needed), and that's it, you will be able to monitor all the API requests of your app, also on a real device.

And you don't need to manage certificates like with Charles. It all works by magic!


FLEX is a great tool to monitor network traffic from your iOS app.

FLEX iOS Screenshot 1

On clicking on any of the requests listed in the above screenshot, I will be redirected to another screen where I can see more details about that request. FLEX iOS Screenshot 2

However, I had a use case where the app which I was working on would redirect the user to Safari. I wanted to monitor the network traffic in Safari as well, but FLEX could only monitor the traffic from your iOS app, not from any other app ( at the time of writing this answer ).

Then I switched to Proxyman to monitor network traffic from the iOS simulator.

  • It has a clear set of instructions on how to set it up with both iOS simulators and Android emulators.
  • It has a simple, intuitive UI, which makes it easy to work with.

enter image description here


Examples related to xcode

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code

Examples related to networking

Access HTTP response as string in Go Communication between multiple docker-compose projects Can't access 127.0.0.1 How do I delete virtual interface in Linux? ConnectivityManager getNetworkInfo(int) deprecated Bridged networking not working in Virtualbox under Windows 10 Difference between PACKETS and FRAMES How to communicate between Docker containers via "hostname" java.net.ConnectException: failed to connect to /192.168.253.3 (port 2468): connect failed: ECONNREFUSED (Connection refused) wget: unable to resolve host address `http'

Examples related to ios-simulator

The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 flutter run: No connected devices Error Running React Native App From Terminal (iOS) How to uninstall downloaded Xcode simulator? Capture iOS Simulator video for App Preview iPhone 6 Plus resolution confusion: Xcode or Apple's website? for development How to enable native resolution for apps on iPhone 6 and 6 Plus? How to access iOS simulator camera Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." Document directory path of Xcode Device Simulator

Examples related to network-monitoring

How to monitor network calls made from iOS Simulator