Search code examples
swiftmacosswiftuiplist

Xcode / plist - run application always in Dark/Light theme on macOS


There exists a property to make app running always in Dark mode -- UIUserInterfaceStyle

problem is.... it doesn't work on macOS.

I have tried to set

  • LIGHT
  • Light
  • light
  • .light
  • 1

file changes inside of the file is correct:

<key>UIUserInterfaceStyle</key>
<string>Light</string>

But result is always is the same - It just doesn't work and app runs with system configuration of theme.

Xcode: Version 11.3.1 (11C504)

MacOS: 10.15.2 (19C57) Catalina

App is based on SwiftUI


Solution

  • If you are looking for the full on SwiftUI version:

    import SwiftUI
    
    @main
    struct SwiftUI_Football_GridApp: App {
        var body: some Scene {
            WindowGroup {
                ContentView().preferredColorScheme(.light)
            }
        }
    }