Old question but I ran into the same situation today.
Ideally It would be nice to be able to set a environment variable in you scheme to turn on dark mode.
So I did some spelunking.
The setting in Xcode to change Appearance while debugging appears to use a private NSSystemAppearanceProxy
object. By setting the appearance of this object from your AppDelegate, you can effect a specific appearance at launch.
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
#if DEBUG // do not include in production code!
if ([NSProcessInfo.processInfo.environment[@"UserInterfaceStyle"] isEqualToString:@"Dark"]){
id proxy = [NSClassFromString(@"NSSystemAppearanceProxy") valueForKey:@"systemProxy"];
[proxy setValue: [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua] forKey:@"appearance"] ;
}
#endif
}
Then add an environment variable UserInterfaceStyle
with the value Dark
to your shame. (turn off or on at will)
Note by setting the appearance on the proxy, rather than the NSApp object, you can still use the runtime appearance setting in Xcode to switch to light mode.