iPhone Simulator - Simulate a slow connection?
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.
-
Install Xcode if you don’t have it.
-
Open Xcode and go to Xcode › Open Developer Tool › More Developer Tools…
- Download Additional Tools for Xcode (matching your current Xcode version)
- Open the downloaded disk image and double-click the Network Link Conditioner .prefpane under “Hardware” to install it.
- There we go!
- Be sure to turn it on. You need to select a profile and enable the network conditioner.
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 usesudo 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
To have this working you need to install 'Network Link Conditioner' on your Mac. See steps mention in Alan's answer
Chris
I work with PHP, MySQL, Objective-C (iPhone), Java (Android), Processing.org & Arduino.
Updated on December 13, 2021Comments
-
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 over 5 yearsAlan's answer should be accepted.
-
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 about 12 yearsawesome just tried that out and it does the business. Thanks!
-
nverinaud over 11 yearsHere is a link to browse available downloads : developer.apple.com/downloads/index.action
-
zack about 11 yearsdoesnt work on Mountain Lion ... stackoverflow.com/questions/12414676/…
-
n00neimp0rtant about 10 yearsNetwork Link Conditioner (tool from Apple that installs as a preference pane) simulates slow connections, packet loss, and latency.
-
Nick Dowell about 10 yearsNetwork Link Conditioner, added in OS X Lion (released in July 2011), makes scripts like this unnecessary.
-
CJT3 almost 10 yearswould be nice if it were app specific, and not for the whole computer
-
jamil ahmed almost 10 yearsYou 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 over 9 yearsYosemite: failed to set speed limit
-
Injectios over 9 yearsI guess doesn't work for Yosemite. I set it to "lossy" but actually didn't get any difference
-
vintagexav about 9 yearsBroken, it says
Failed to set speed limit
-
Maria almost 9 yearsThank you so much for this answer! Works fine with Yosemite (10.10.4).
-
lifeisfoo over 8 yearsThe right way to do this is explained by Alan H. answer.
-
Mohit Singh over 7 yearsfor Xcode 8, this is included in "Additional Tools for Xcode 8" (instead of "Hardware IO Tools for Xcode")
-
Alan H. over 7 years@MohitSingh Thanks. I have updated the answer above.
-
Thomás Pereira over 7 yearsAmazing! Thank you.
-
Display Name over 5 years"I am no longer able to maintain this project. Please feel free to fork and take ownership."
-
Leo over 4 yearsThere seem to be no Additional Tools for Xcode 10.3?
-
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. over 4 yearsOr, 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 over 2 yearsfor 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 over 2 yearsNetwork Link Conditioner of Additional Tools for Xcode 13.2 beta works well on Monterey on M1.
-
romin21 about 2 yearsExactly what I needed, thanks!