Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Application is agent" doesn't work in Swift

I'm working on a status bar app in Swift. I tried to hide the window by adding Application is agent (UIElement) item and set it to YES, but it just doesn't work - it always shows the window and the menu bar.

My storyboard:

enter image description here

Info.plist:

enter image description here

What can I do ?

like image 282
ChangJoo Park Avatar asked Dec 05 '25 20:12

ChangJoo Park


1 Answers

The option for "Target -> Info -> Curstom macOS Appli.. : Application is agent (UIElement)" only hide the App from Dock

To hide the window on SwiftUI you need to change your App Scene:

var body: some Scene {
    Settings{
        EmptyView()
    }
}

Alternatively you can change the ApplicationDelegate

func applicationDidFinishLaunching(_ notification: Notification) {
    if let window = NSApplication.shared.windows.first {
        window.close()
    }
    ...
 }
like image 52
Cleber Neitzke Avatar answered Dec 08 '25 14:12

Cleber Neitzke



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!