I have developed several document-based (NSDocument) applications for macOS is Cocoa. Now, I'm playing with a document app project in SwiftUI. If I launch the application out of box, a file-select panel will open just as you see in TextEdit. (Please see the picture below) How do we prevent it from appearing? I would rather show a blank window, which in fact appears if I just press Command + N. Thanks.
You can use .defaultLaunchBehavior(.suppressed)
to suppress the scene in the absence of any previously restored scenes. For example:
@main
struct WritingApp: App {
var body: some Scene {
DocumentGroup(newDocument: WritingAppDocument()) { file in
StoryView(document: file.$document)
}
.defaultLaunchBehavior(.suppressed)
}
}