Benjamin Kindle
Benjamin Kindle

Reputation: 1844

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

Upvotes: 4

Views: 729

Answers (2)

RyanM
RyanM

Reputation: 4594

Same problem and I fixed by removing UISceneDelegateClassName (actually removed all of UISceneConfigurations) from the plist.

I still need a scene delegate, so have application(:configurationForConnecting:options:) implemented in app delegate (See the doc comment for UIApplicationDelegateAdaptor for how it expects this to be implemented).

My theory is that it was trying to get the window from my scene delegate, but I didn't have window implemented.. Not sure though, and now that I fixed it once I'm unable to repro again by reverting the plist back. slightly scary :(

Upvotes: 0

Benjamin Kindle
Benjamin Kindle

Reputation: 1844

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.

Upvotes: 6

Related Questions