How to turn on dark mode in the iOS Simulator
Codemia Knowledge Hub ·
To turn on dark mode in the iOS Simulator, open Settings > Display & Brightness on the simulated device and select Dark, or use the Environment Overrides panel in Xcode's debug bar. From the terminal, xcrun simctl ui <device> appearance dark switches instantly. All three do the same thing; the terminal command is fastest if you switch often.
If your colors, images or text assume a light background, dark mode exposes that immediately, and the Simulator lets you check both appearances without a physical device.
Settings app in the Simulator
This mirrors what a user does on a real iPhone or iPad.
- Open the Simulator (launch it from Xcode or run
open -a Simulatorin Terminal). - Go to Settings > Display & Brightness.
- Under Appearance, tap Dark.
The change applies immediately to every app on the device, including the home screen and system UI. Tap Light to switch back.
Under Display & Brightness > Automatic you can also set a schedule, which is useful for testing dynamic appearance changes without toggling by hand.
Xcode Environment Overrides
The fastest option when you are already debugging in Xcode.
- Run your app on the Simulator from Xcode.
- In the debug area's bottom toolbar, click the Environment Overrides button (a small slider icon, also under Debug > View Debugging > Environment Overrides).
- Toggle Interface Style to Dark.
The override applies while your app runs and does not change the Simulator's system setting, so other apps keep their previous mode. Because it is a single click, it suits rapid back-and-forth while inspecting layouts.
xcrun simctl ui from the terminal
simctl controls the Simulator from Terminal, which makes it the best choice for scripts, CI pipelines and keyboard users.
booted targets the running Simulator. If several are running, use a specific device UDID:
Screenshot tests in both modes
Set the appearance before launching the test suite:
Comparing the three methods
| Method | Speed | Requires Xcode Debug Session | Scriptable | Persists After App Restart |
| Settings app | Slow (navigate through UI) | No | No | Yes |
| Environment Overrides | Fast (one click) | Yes | No | No (override only) |
xcrun simctl ui | Fastest (command line) | No | Yes | Yes |
Because Environment Overrides do not persist, testing only with them misses bugs that appear when the app launches in dark mode (for example, launch screen colors). Test the initial launch through Settings or simctl too.
Making your app adapt to dark mode
Semantic system colors
UIKit semantic colors adapt automatically. Hard-coded colors like UIColor.white or UIColor.black do not, and look wrong in the opposite mode.
Custom dynamic colors
When system colors are not enough, define colors that resolve from the current trait collection:
Asset catalog variants
- Select an image or color in Assets.xcassets.
- In the Attributes Inspector, set Appearances to Any, Dark (or Any, Light, Dark).
- Drag the right assets into each slot.
UIKit picks the correct variant at runtime with no code changes. Without dark variants, a bright logo on a dark background, or a dark icon on a dark background, becomes jarring or invisible.
SwiftUI
SwiftUI reacts to appearance through @Environment:
In most cases the built-in semantic colors (Color.primary, Color.secondary, Color(.systemBackground)) are enough and you do not need to read colorScheme.
Reacting to appearance changes at runtime
Users can switch modes while your app is in the foreground. If you cache colors at startup without listening for trait changes, the UI shows stale colors. In UIKit, override traitCollectionDidChange to update non-UIKit components:
This callback is for UIKit-based views. In SwiftUI, use @Environment(\.colorScheme) instead.
Debugging dark mode issues
- Contrast: the Accessibility Inspector (Xcode > Open Developer Tool > Accessibility Inspector) overlays contrast information on the Simulator in real time so you can check ratios against WCAG.
- Hard-coded colors: the View Debugger (Debug > View Debugging > Capture View Hierarchy) shows which colors each view uses. Look for white backgrounds and black text that do not adapt.
Forcing an appearance per view controller
This helps compare the two modes side by side in split-view debugging. It is a debugging tool: shipping overrideUserInterfaceStyle = .dark in production disables the user's system preference for your whole app.
Related reading
- How to use data-binding with Fragment
- How to use Facebook iOS SDK on iOS 10
- How to use generic protocol as a variable type
- How to use Git properly with Xcode?
- How to use fixture-context objects with async specs in ScalaTest?
- How to use JUnit to test asynchronous processes
- How to use icons and symbols from Font Awesome on Native Android Application
- How to use LocalBroadcastManager?
.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.