How to turn off the network (airplane mode) in the iOS Simulator
Codemia Knowledge Hub ·
The iOS Simulator has no airplane mode toggle or network switch, because it shares the host Mac's network stack. To simulate being offline, disable networking on the Mac, use Network Link Conditioner to drop all traffic, or build a network abstraction into your app that test builds can switch to offline.
Why the Simulator has no airplane mode
On a physical device, airplane mode is a hardware-level toggle for the cellular radio, Wi-Fi chip and Bluetooth. The Simulator is a user-space macOS process that does not emulate network hardware. Every request from a simulated app goes through the Mac's own TCP/IP stack and interfaces, so you cannot disable networking for the Simulator alone without affecting the whole Mac.
Turning off the Mac's Wi-Fi
This is the most direct option, and it takes the entire machine offline. From the menu bar, click the Wi-Fi icon and choose "Turn Wi-Fi Off" (unplug the cable if you are on Ethernet). From the command line:
A script can wrap the cycle so networking is restored when you finish:
The cost is that the Mac loses internet access for the duration: IDE features, package managers, documentation lookup and other network tools stop working.
Simulating offline with Network Link Conditioner
Network Link Conditioner (NLC) is an Apple developer tool that applies latency, bandwidth limits and packet loss to network traffic. It cannot switch the network off outright, but it can degrade it until it behaves like being offline.
Installing it
NLC ships in the "Additional Tools for Xcode" package:
- Open Xcode > Settings > Components.
- Or download from developer.apple.com/download/more and search "Additional Tools."
- Install the Network Link Conditioner preference pane from the downloaded DMG.
It then appears in System Settings > Network Link Conditioner.
Creating a 100% packet loss profile
- Open Network Link Conditioner in System Settings.
- Click "Manage Profiles" then click the "+" button.
- Configure the profile:
| Parameter | Downlink | Uplink |
| Bandwidth | 0 kbps | 0 kbps |
| Packets Dropped | 100% | 100% |
| Delay | 0 ms | 0 ms |
- Name it "100% Packet Loss" and save.
- Select the profile and toggle NLC on.
With the profile active, every request from the Simulator (and the Mac) times out. Connections are attempted but every packet is dropped, so your app sees the same timeouts and network errors as a real offline device.
From the command line
NLC itself is built on the dnctl/pf dummynet packet shaper, which you can drive directly:
Stubbing requests inside the app with URLProtocol
The most precise approach leaves the system network alone and injects an offline network layer into your app during testing. A custom URLProtocol subclass can intercept every request and fail it:
Toggling it with a launch argument
Pass the argument in your Xcode scheme under "Arguments Passed On Launch", or from UI tests:
This is the only approach that affects the Simulator alone without disrupting the Mac's connectivity.
Blocking traffic through a proxy
Charles Proxy or mitmproxy can intercept Simulator traffic and block requests selectively:
The Simulator inherits the Mac's proxy settings, so set the HTTP proxy in System Settings > Wi-Fi > Advanced > Proxies on the Mac.
Comparing the options
| Method | Scope | Simulator-only | Precision | Setup effort |
| Disable Mac Wi-Fi | System-wide | No | Binary on/off | None |
| Network Link Conditioner | System-wide | No | Configurable (latency, loss, bandwidth) | Low |
| URLProtocol stubbing | App-level | Yes | Full control per request | Medium |
| Proxy (Charles/mitmproxy) | System-wide or app-scoped | Partially (via proxy config) | Per-request blocking | Medium |
| NWPathMonitor override | App-level | Yes | Status reporting only | Low |
Testing transitions between online and offline
Real users move in and out of connectivity, so test the transitions as well as the offline state:
Toggle Network Link Conditioner on and off during a running session, and the NWPathMonitor callbacks fire as they would on a real device.
Offline testing gotchas
NWPathMonitor reports the Mac's state. If you disable Mac Wi-Fi, the monitor correctly reports .unsatisfied, but you cannot make it report offline while the Mac is online, short of the URLProtocol approach.
Testing only the offline state. Check that the app recovers when connectivity returns: pending requests retry, cached data refreshes and the UI leaves its error state.
Reachability libraries that only check interfaces. Many legacy Reachability wrappers check whether an interface is available, not whether a host is reachable. In the Simulator the interface stays "available" even when NLC drops every packet, so test with real HTTP requests.
Leaving Network Link Conditioner on. NLC persists across reboots, and a forgotten "100% Packet Loss" profile breaks all networking on your Mac. Add a reminder, or use the command-line approach, which resets on reboot.
Related reading
- Is it possible to evenly distribute buttons across the width of a LinearLayout
- Is it possible to have multiple styles inside a TextView?
- Is it possible to have placeholders in strings.xml for runtime values?
- Is it possible to install iOS 6 SDK on Xcode 5?
- Is it possible to execute code once before all tests run?
- Is it possible to mark springboot tests so they run only when certain profile is active
- Is it possible to institute a timeout for SKStoreProductViewController loadProductWithParameters?
- Is it possible to obtain a dynamic table view section header height using Auto Layout?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseData Structures & Algorithms practice on Codemia
Step through 300+ coding interview problems with animated visualisers that show the data structure changing as the code runs. The Blind 75 are free.