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?
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.