Can I disable the New Document menu item without losing the Open menu item as well?

Hello all,

I have a SwiftUI app which can view some document formats, but not create new ones.

I would like to disable the File > New menu item as it is not needed.

I see you can use CommandGroup(replacing: .newItem){} to do this, however then I lose both the Open and Open Recent menu items as well.

Is it possible to either remove only the New item from the File menu?

Or perhaps remove all three then manually add back the Open item?

Any advice would be gratefully received.

Thank you.

I think I have found my own answer now.

If you only define document types in your Info.plist with a CFBundleTypeRole of Viewer, then create your DocumentGroup like so:

DocumentGroup(viewing: MyDocument.self) { file in
  ContentView(document: file.$document)
}

(Note the viewing label rather than newDocument)

Then your File menu will have the New item automatically disabled as there are no types defined which can create a document.

Can I disable the New Document menu item without losing the Open menu item as well?
 
 
Q