While I am developing the iOS app I need to test it in simulator with dark mode option so I can get more clarity about the app UI. But when I go to the Setting I am not gett
In Settings, scroll down to Developer and then Dark Appearance…
Update
In addition to the above, there are now many other ways to enable dark appearance in the simulator, as shown in the many great answers below.
• Change Environment Overrides from Xcode (@AshCameron)
• Toggle Appearance ⇧⌘A from the Simulator menu (@Shredder2794)
• Update from the command line using xcrun simctl ui booted appearance …
(@blackjacx, @tadija)
• Programmatically using overrideUserInterfaceStyle = .dark
(@thisIsTheFoxe)
• Specify UIUserInterfaceStyle
in your info.plist (@DhavalGevariya)
• Use SimGenie from Curtis Herbert… https://simgenie.app
You can use the "Toggle Appearance" setting from the Simulator menu dropdown (Shift-Command-A):
from terminal:
xcrun simctl ui booted appearance light
xcrun simctl ui booted appearance dark
There are two ways to enable dark mode in Simulator. Note: Make sure that you’re using iOS 13 simulator. X-D
Solution 1: Change build settings
Solution 2: Programmatically
Simply add this code block in your ViewController file.
override func viewDidLoad() {
super.viewDidLoad()
#if DEBUG
// This changes appearance only for debug mode
overrideUserInterfaceStyle = .dark
#endif
}
Check this apple docs for more details.
Alternatively, you can also switch the appearance programmatically (docs):
override func viewDidLoad() {
super.viewDidLoad()
#if DEBUG
// change the appearance only while testing
overrideUserInterfaceStyle = .dark
#endif
}