Using SettingsLink from MenuBarExtra does not activate the app

I have a Utility app that does not have a Dock icon and runs in the menu bar. On macOS Sonoma (14 DB 1) you cannot use anymore the workaround that we used on previous versions of the macOS, as you get a warning that you should use SettingsLink.

NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)

But the issue is, that before I usually were calling as well NSApp.activate(ignoringOtherApps: true) to activate the app. As clicking on the MenuBar app icon does not do that.

The SettingsLink only opens the Settings Scene, but does not actually activates the app. I could not find a workaround how to do so. As I cannot inject my code in SettingsLink call.

Any ideas how I can activate my app when SettingsLink is called?

I managed to get it working even when the app wasn't active or had any windows open using the code below. On Apple's Developer Documentation Apple's Developer Documentation it is stated that it will request a window to become active, even if non are present. You might want to combine this with an if statement to check whether or not a person is using MacOS Sonoma or an older version like MacOS Ventura.

Settings {
      ContentView()
}

MenuBarExtra("Test", systemImage: "circle.fill"){
      SettingsLink{
           Text("Settings")
      }.keyboardShortcut(",", modifiers: .command)
 }

I had the same problem as you, but I came up with this code which worked.

Using SettingsLink from MenuBarExtra does not activate the app
 
 
Q