iosswiftswiftui

Black screen on launch when migrating to SwiftUI application flow


I have done all of the refactoring to migrate from SceneDelegate to using a SwiftUI App and Scene with WindowGroup. I noticed that when the app is updated from the previous version, the app launches to a black screen, and you can't do anything with it. No matter how many times you quit and relaunch the app, nothing is navigable. I can log something in the init function of the App struct, but not in the onAppear modifier.

Uninstalling the app and installing it fresh works fine, but I don't want users to have to do this (I verified that this issue also happens when updating from my released app to a TestFlight beta).


Solution

  • The best way to get around this seems to be to leave the info.plist configuration that tells it to look for the SceneDelegate class (UISceneDelegateClassName), but delete the scene delegate. This will cause warnings in the console on launch, but the black screen issue will stop happening.