-
-
Notifications
You must be signed in to change notification settings - Fork 0
Description
When a document-based app supports iCloud, AppKit automatically displays the Open dialog during the app’s open event if no document windows are available.
At present, there does not appear to be any AppKit API that allows developers to suppress this behavior.
The traditional applicationShouldOpenUntitledFile(_:) method in NSApplicationDelegate looks suitable for this purpose at first glance; however, this method is only invoked when the app does not support iCloud Drive.
Based on my investigation of the stack trace, it appears that AppKit directly calls NSDocumentController’s openDocument(_:) action during application launch, leaving no opportunity for third-party developers to intervene.
In my document-based application, I would like to offer an option to create a new untitled document at launch instead of showing the Open dialog, so that users can start writing immediately.
Currently, the app overrides NSDocumentController’s openDocument(_:) and customizes the behavior there.
However, this approach is unstable because the timing of the open event is not always detectable.
I recently discovered that SwiftUI’s .defaultLaunchBehavior(.suppressed) achieves the behavior I am looking for, but only in SwiftUI.
My app still relies heavily on AppKit, so migrating entirely to SwiftUI is not yet feasible.
I also found the NSShowAppCentricOpenPanelInsteadOfUntitledFile defaults key, which changes this behavior.
However, this key is effectively private, its behavior is undocumented, and it is unsuitable for use when the app changes its behavior based on user settings.
I imagine that when iCloud Drive was first introduced, there was an intention to promote it, but I don't think that's necessary anymore.
For these reasons, I believe AppKit should provide an official API that allows document-based apps to suppress the automatic Open dialog during launch even when iCloud Drive is enabled.
Environment
- macOS: Version 26.2 Beta 3 (25C5048a)
- Xcode: Version 26.2 beta 2 (17C5038g)