Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 696
Andrew Avatar asked Oct 24 '25 15:10

Andrew


2 Answers

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)
        }
    }
}
like image 159
erickva Avatar answered Oct 26 '25 05:10

erickva


The problem is that UIInterfaceStyle is a UIKit feature. It is for tvOS/iOS. It does nothing on MacOS. You are writing a MacOS app, not an iOS app. Thus your changes to the Info.plist naturally have no effect.

The way to opt out of light/dark mode on MacOS is completely different, and is documented here:

https://developer.apple.com/documentation/appkit/nsappearancecustomization/choosing_a_specific_appearance_for_your_macos_app

Basically you want to use the NSRequiresAquaSystemAppearance key (though it would be better just to adopt dark mode compatibility).

like image 35
matt Avatar answered Oct 26 '25 05:10

matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!