Prevent creating "Default configuration" scene on macCatalyst at startup

I want to create an Welcome window for my app to show it at the first launch. While this window is visible, no other window/scene should be created. The user should click a "Continue" button to be able to use the app, and create new scenes.

I defined two scenes, "Default Configuration" and "Welcome", and at the end of "application(_ :willFinishLaunchingWithOptions:)" I display the Welcome scene.

It works ok, but a default scene is also created at startup while the Welcome window/scene is visible.

I also tried using a macOS plugin. I defined the Welcome window in a xib in the plugin, and launched it from there. I did set "Visible at Launch", but that did not prevent a second scene to be created at startup, with the "Default Configuration".

How can I temporarily prevent new scenes to be created?

Answered by Frameworks Engineer in 724620022

You can create your own welcome scene by defining a new scene configuration, and overriding application(_:configurationForConnecting:options:) to return the appropriate scene configuration as needed. To distinguish between document scenes and the default scene, always pass a NSUserActivity when calling requestSceneSessionActivation to create new document scenes.

You can delete the default File/New menu item by overriding buildMenuWithBuilder in your app delegate and deleting the UIMenuNewScene item, and adding your own menu item that you can validate as needed.

Please make sure to test the app behavior during State Restoration if you do this.

Is there anybody using macCatalyst with multiple scenes or it's only good for simple, one window apps?? No documentation, no way to change anything scene related, unless you dive into AppKit, it looks like it's a waste of programmer's time :(

L.E. ..to work on a doc app with multiple windows. For the rest it works just fine, I'm close to launching my app ported from iOS and it helped tremendously.

Accepted Answer

You can create your own welcome scene by defining a new scene configuration, and overriding application(_:configurationForConnecting:options:) to return the appropriate scene configuration as needed. To distinguish between document scenes and the default scene, always pass a NSUserActivity when calling requestSceneSessionActivation to create new document scenes.

You can delete the default File/New menu item by overriding buildMenuWithBuilder in your app delegate and deleting the UIMenuNewScene item, and adding your own menu item that you can validate as needed.

Please make sure to test the app behavior during State Restoration if you do this.

Prevent creating "Default configuration" scene on macCatalyst at startup
 
 
Q