Show main window of SwiftUI app on macOS Sequoia after auto start

It seems like it is no longer possible to open the main window of an app after the app has been launched by the system if the "Auto Start" functionality has been enabled.

I am using SMAppService.mainApp to enable to auto start of my app. It is shown in the macOS system settings and the app is automatically started - but the main window is not visible.

How can I change this behaviour so the main window of the app is always visible when started automatically?

I have not noticed this behaviour before the release of macOS Sequoia. My app is using Swift 6 and the latest version of macOS and Xcode.

Regards

I have the same issue on Sequoia. If I try to invoke the app via command line, the main window does not open automatically anymore. If I click the dock icon, the window appears. I tried everything, playing with appDelegate and different SwiftUI techniques, but nothing seem to help. I suspect this is a SwiftUI regression.

I too have this problem with an SwiftUI application.
The problem started when I build the application with Xcode 16. When build with an earlier version there is no auto start problem.
I have looked for a solution, but except here, I didn't see any mention of this issue.

Lets try to summon Quinn, he will know what to do :)

I was able to work around the issue, but it might not work for SwiftUI exclusive apps. My application is a mix of SwiftUI and AppKit, so I could build an NSWindow having my SwiftUI views as NSHostingView.

Also window.makeKeyAndOrderFront(nil) was necessary to show the window at application start.

I'm only experiencing this when I have command line arguments. Something like this

~ open /Applications/My.app --args one two

Have same problem. Launchd launches my swiftUI app at startup and the icon show on the dock but the main window is never created. When right click on icon and select "Show all windows" it shows nothing. When clicking the dock icon it finally opens a main window.

Show main window of SwiftUI app on macOS Sequoia after auto start
 
 
Q