Hi, everyone
I have an app already in production that uses SwiftUI
's lifecycle (paired with an AppDelegate
). Due to some specific behaviour of the app, we decided to migrate the app to use UIKit's
lifecycle, adding the corresponding SceneDelegate
to the app, as well as modifying the Info.plist
file accordingly to accommodate to these new changes.
Although everything seems to work when installing the app from zero, when installing it on top of another version, the screen goes black and the user cannot interact with the app at all unless they reinstall it completely. As I've read online, iOS is reusing the window configuration from the previous execution of the app. I know this because the AppDelegate
's application(application:connectingSceneSession:options)
is not being called when coming from a previous version of the app.
I would love to know what can I do to make this work because, as you may understand, we cannot ask our user base to reinstall the application.
Thank you very much.
After messing around with it I've found the problem and how to fix it.
The problem was that there's an option in the Build Settings
of Xcode called Application Scene Manifest (Generation)
by default when the project is created with SwiftUI (I don't know about UIKit) this option is set to YES.
This configuration seems to override whatever values you set in your Info.plist
regarding the Scene Configuration,
thus leaving the app with a black screen with no content. The solution wat setting that configuration to NO
and, magically, the screen appeared correctly on my device.
As I've not seen anything related to this setting anywhere on the internet, I'll mark this post as the answer in hopes that anyone fighting with this behaviour can find this post and, maybe, make their lives easier.