iPhone Simulator - Simulate a slow connection?

67,025

Solution 1

An app called SpeedLimit

https://github.com/mschrag/speedlimit

Works great.

chris.

Solution 2

How to install Apple’s Network Link Conditioner

These instructions current as of October 2019.

Warning: If you just upgraded to new version of macOS, make sure you install the very latest Network Conditioner (in Additional Tools for Xcode) or it may silently fail; that is, you will turn it on but it won’t throttle anything or drop any packets.

Update: As of Xcode 11, there may be an even simpler way to simulate network conditions on tethered devices; see this blog post. For how to affect simulated devices, continue below, as before.

  1. Install Xcode if you don’t have it.

  2. Open Xcode and go to Xcode › Open Developer Tool › More Developer Tools…

Screen shot of navigating the menu as described

  1. Download Additional Tools for Xcode (matching your current Xcode version)

Additional IO Tools download link

  1. Open the downloaded disk image and double-click the Network Link Conditioner .prefpane under “Hardware” to install it.

pref pane in DMG

system preferences showing installation prompt

  1. There we go!

Screen shot of the preference pane

  1. Be sure to turn it on. You need to select a profile and enable the network conditioner.

enter image description here

Caveat

This won't affect localhost, so be sure to use a staging server or co-worker's computer to simulate slow network connections to an API you’re running yourself. You may find https://ngrok.com/ helpful in this regard.

Solution 3

"There's an app for that!" ;) Apple provides "Network Link Conditioner" preference pane that does the job quite well.

  • for Xcode versions prior to 4.3, the pane installer can be found in your Developer folder, e.g. "/Developer/Applications/Utilities/Network Link Conditioner", after installation, if daemon fails to start and you don't want to reboot your machine, just use sudo launchctl load /system/library/launchdaemons/com.apple.networklinkconditioner.plist
  • if you are already done with Developer folder, you can install the pane as a part of "Hardware IO Tools for Xcode" package available via Mac Dev Center additional downloads section.

Link to download page (you must log in with your Apple ID): https://developer.apple.com/downloads/index.action
(credits to @nverinaud)

Solution 4

It also worth mentioning that Xcode also has a built in way for devices, not simulator.

  • Just go 'Devices and Simulator' (cmmd+shift+2)
  • Select your device
  • Scroll down til you find 'Device Conditions'
  • Set your desired profile
  • Hit Start

enter image description here

To have this working you need to install 'Network Link Conditioner' on your Mac. See steps mention in Alan's answer

Share:
67,025
Chris
Author by

Chris

I work with PHP, MySQL, Objective-C (iPhone), Java (Android), Processing.org & Arduino.

Updated on December 13, 2021

Comments

  • Chris
    Chris over 2 years

    Is there a way to slow down the internet connection to the iPhone Simulator, so as to mimic how the App might react when you are in a slow spot on the cellular network?

    • Stanislav Mayorov
      Stanislav Mayorov over 5 years
      Alan's answer should be accepted.
    • Chris
      Chris over 4 years
      @StanislavMayorov this question is from 9 years ago. Alan then gave an updated answer 4 years later. It is now 5 years after that. Sorry I am not going through and reconsidering accepted answers on my old questions.
  • Max MacLeod
    Max MacLeod about 12 years
    awesome just tried that out and it does the business. Thanks!
  • nverinaud
    nverinaud over 11 years
    Here is a link to browse available downloads : developer.apple.com/downloads/index.action
  • zack
    zack about 11 years
    doesnt work on Mountain Lion ... stackoverflow.com/questions/12414676/…
  • n00neimp0rtant
    n00neimp0rtant about 10 years
    Network Link Conditioner (tool from Apple that installs as a preference pane) simulates slow connections, packet loss, and latency.
  • Nick Dowell
    Nick Dowell about 10 years
    Network Link Conditioner, added in OS X Lion (released in July 2011), makes scripts like this unnecessary.
  • CJT3
    CJT3 almost 10 years
    would be nice if it were app specific, and not for the whole computer
  • jamil ahmed
    jamil ahmed almost 10 years
    You can download "Hardware IO Tools" from Apple's developer tools site now. They update it for new releases of Xcode (and thus OSX): In Xcode, click Xcode -> Open Developer Tool -> More Developer Tools..., login, find the latest archive, download, copy the files somewhere, double click the Network Conditioner preference pane thingy, install it... yay!
  • Injectios
    Injectios over 9 years
    Yosemite: failed to set speed limit
  • Injectios
    Injectios over 9 years
    I guess doesn't work for Yosemite. I set it to "lossy" but actually didn't get any difference
  • vintagexav
    vintagexav about 9 years
    Broken, it says Failed to set speed limit
  • Maria
    Maria almost 9 years
    Thank you so much for this answer! Works fine with Yosemite (10.10.4).
  • lifeisfoo
    lifeisfoo over 8 years
    The right way to do this is explained by Alan H. answer.
  • Mohit Singh
    Mohit Singh over 7 years
    for Xcode 8, this is included in "Additional Tools for Xcode 8" (instead of "Hardware IO Tools for Xcode")
  • Alan H.
    Alan H. over 7 years
    @MohitSingh Thanks. I have updated the answer above.
  • Thomás Pereira
    Thomás Pereira over 7 years
    Amazing! Thank you.
  • Display Name
    Display Name over 5 years
    "I am no longer able to maintain this project. Please feel free to fork and take ownership."
  • Leo
    Leo over 4 years
    There seem to be no Additional Tools for Xcode 10.3?
  • Alan H.
    Alan H. over 4 years
    @leo, just use the current Additional Tools for the major version of Xcode you have. For example, use Additional Tools for Xcode 11 if you have Xcode 11.1 installed.
  • Alan H.
    Alan H. over 4 years
    Or, more accurately, use the latest available Additional Tools, up to the version of Xcode you have. For example, use Additional Tools for Xcode 11 if you have Xcode 11.1 installed, since currently there is no version specifically for 11.1.
  • Stefan Majiros
    Stefan Majiros over 2 years
    for XCode 13.0 running on macOS Big Sur (11.6) you need to install Additional tools for Xcode 12.5 (instead of Additional tools for Xcode 13). developer.apple.com/forums/thread/…
  • Meng-Yuan Huang
    Meng-Yuan Huang over 2 years
    Network Link Conditioner of Additional Tools for Xcode 13.2 beta works well on Monterey on M1.
  • romin21
    romin21 about 2 years
    Exactly what I needed, thanks!