How to simulate poor network conditions on iOS Simulator and iPhone

How to simulate poor network conditions on iOS Simulator and iPhone

While developing mobile apps that require internet connectivity, it's significant to handle poor network conditions. Because mobile app users will likely to have a much slower network than we use while developing.

As a developer, you didn’t want to throw away your invaluable time looking for a location with a poor network to test the app. So there are some ways to simulate poor network conditions during development.

Simulate Poor Network on iOS Simulator

Apple’s official tool to simulate network connections on macOS for testing purposes is the Network Link Conditioner.

image.png

  • Search for “Additional Tools for Xcode” package [Note: You may need to sign in first]

  • Download the appropriate release package as per your Xcode version.

image.png

  • Once the download has finished, open the DMG file and navigate to the Hardware directory.

  • Install the “Network Link Conditioner.prefPane” in your System Preferences by double-clicking on the icon.

image.png

  • Once you install, a new item has been added to your System Preferences which will allow you to throttle your network connection speed.
  • To simulate the network, turn on the “Network Link Conditioner” and select the preset profile (100% Loss, Edge, DSL, 3G, LTE, etc.) of your choice.
  • You can also add a new custom Profile of your choice through Manage Profiles…

image.png

CAVEAT:

This will impact your computer internet connection in addition to your iPhone simulator. So, when you’re done testing, be sure to turn this off.

Simulate Poor Network on iPhone

From iOS 6 onwards, the network link conditioner for testing on the device is already built-in. So It’s really easy to simulate a bad internet connection on your iPhone.

  • Open the Settings app and navigate to the Developer option.
  • Select the Network Link Conditioner under NETWORKING option.
  • Now enable the Network Link Conditioner & choose the network profile you want, and start testing how your app works in different conditions.

image.png

To enable Developer menu on your iPhone/iPad:

  • Connect your device to Xcode.
  • Your device will ask you to trust your computer. Click on Yes.
  • You can now access the Developer settings on your device from the Settings menu.

Simulate Poor Network on iPhone Using Xcode

From the Xcode 11 onwards, you can now simulate a network condition right from the Xcode.

  • Open Xcode and navigate to WindowDevices and Simulators (⇧⌘2)
  • In the left side click on the Devices and select the device.
  • On the right side you should see the DEVICE CONDITIONS menu where you can simulate a network condition.
  • From the Condition dropdown choose Network Link option and choose the network profile of your choice for testing.
  • Hit the Start button.

image.png

Now you can see the gray developer icon on your device statusbar indicating that the network link conditioner is running.

image.png

CAVEAT:

  • Don’t forget to hit stop button when you are done with your testing. Once network link conditioner stops, the grey icon will no loner visible on your statusbar. You can also stop the network link conditioner by clicking on the grey icon on the status bar.

Questions?

Please feel free to comment below, if you have any questions.

If you like this article, feel free to share it with your friends and leave me a comment. Also, click on the 👏 clap button below to show how much you like the article.

Thanks for reading! 👨🏼‍💻

You can find me on:

Twitter | LinkedIn | GitHub | Medium | HackerRank | LeetCode | Stack Overflow

Did you find this article valuable?

Support Milan Panchal by becoming a sponsor. Any amount is appreciated!