Beginning Networking with URLSession

Sep 13 2022 · Swift 5.6, iOS 15, Xcode 13.4.1

Part 2: Download Data

16. Simulate Different Network Speeds

Episode complete

Play next episode

Next
About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 15. Grouping Requests Next episode: 17. Pause, Resume & Cancel Downloads

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 16. Simulate Different Network Speeds

More Downloads - Additional Tools - Apple Developer

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

In a previous episode, you put together a demo that showed how to display download progress to the user. However, the progress might have updated too fast if you have really good internet. It might be easy for us to assume that everyone else shares this speed, but that's not the case. People have all sorts of network speeds for a variety of reasons. It's critical that you test your app at different network speeds to see how it responds. There are a few ways. With Xcode, you can simulate a poor network on your device. You need to tether your device to Xcode, and from the Devices and Simulators option, you can select the type of network for the device to experience. If you're testing on the simulator, you can also download the Network Link Conditioner tool. This plugs directly into system preferences and allows you to change the speed of the network. Finally, on your device itself, you can access the developer settings from the settings app. You will need to connect your device to your development machine while running Xcode. When prompted, confirm the trust settings, and you should see the developer menu. From there, you simulate bad network conditions using the Network Link Conditioner. To test different network speeds on the simulator, you'll need to download some additional tools from Apple. Head over to the Apple Developer Portal's downloads page and log in. In the top right corner, click More, and search for additional tools. From the list of options, select Additional Tools for Xcode. This will be a DMG for you to download. Once downloaded, open it up and look in the Hardware folder. You'll find a tool called Network Link Conditioner.PrefPane. Double-click on it to install it. You will now see a new tool in your System Preferences. Click on it to open it. This will now control the network traffic out of your computer. In this case, I want to simulate a very bad network. I'll turn on the Conditioner and navigate to a website. This should slow down your connection as you begin testing on different websites or as you use your computer. To simulate different network conditions on your device, make sure to plug in a device to your development computer. Open Xcode and select Window and then Devices and Simulators. Select your device and, at the bottom, you will see a section labeled Device Conditions. Click the dropdown and select Network Link. You'll see that you have lots of different options to simulate. Select your option and then click Start. Your device will now have these network conditions activated throughout development. If you also want to enable this from your device itself, you can go to the settings app under the Developer Settings option. Don't forget to stop the Network Link Conditioner as well as the System Preferences Pane option And there you have it. The Network Link Conditioner allows you to simulate different network speeds and conditions without having to jump through hoops. Don't forget to turn off the tool on your Mac or iOS device. Otherwise, the next episodes will take forever to load. Speaking of which, join me in the next episode where I'll show you how to pause, resume, and cancel downloads. See you in a bit.