iPhone Simulator - Simulate a slow connection?

前端 未结 6 496
离开以前
离开以前 2021-01-29 18:26

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?

6条回答
  •  独厮守ぢ
    2021-01-29 18:55

    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…

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

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

      system preferences showing installation prompt

    5. There we go!

      Screen shot of the preference pane

    6. Be sure to turn it on. You need to select a profile and enable the network conditioner with the big toggle that should be familiar from the Time Machine prefpane.

      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.

提交回复
热议问题