In my iOS/macOS app the user can choose between a light and a dark appearance.
This is done by setting the overrideUserInterfaceStyle of the app window, for example
window.overrideUserInterfaceStyle = .dark
It works fine on iOS/iPadOS.
On macOS (Catalyst) the app uses an NSToolbar, which always appears in the mode chosen in the system settings, regardless what ist set for the overrideUserInterfaceStyle of the window (see screenshot).
Since this is not a good visual impression, I would like to know how I can set light/dark mode for the NSToolbar too.
This can be done by adding an macOS plugin which has access to the whole AppKit API. Instructions can be found here: How to Access the AppKit API from Mac Catalyst Apps
Then you can set the desired appearance there at runtime, for example:
NSApplication.shared.appearance = NSAppearance(named: .darkAqua)