SwiftUI app cycle and opening an app document

I am writing a SwiftUI app cycle macOS app and trying to open a custom app document. I have added the appropriate entries to the Info.plist file and the document does open in my app.

I am using NSApplicationDelegateAdaptor to provide an application delegate.

The application(_ application: NSApplication, open urls: [URL]) app delegate method does get called but urls is an empty array. Furthermore an additional app window opens when opening my document.

My app is not a document based app and my custom document is not associated with a class or an NSDocument thing.

Is this broken in SwiftUI app cycle based apps or am I missing something? Is there a solution?

Seems like I have found a solution which is to add .handlesExternalEvents(matching: []) to the WindowGroup.

SwiftUI app cycle and opening an app document
 
 
Q