Swift – Opt out of UISceneDelegate/SwiftUI on iOS

ios13swiftswiftuixcode

I'm currently using Xcode 11 Beta 5. Within my application, it runs fine on iOS 12 and under. However, on iOS 13 it looks like it's using the UIScene by default. This is causing my app to not do anything.

When the app launches on fresh install, there is a terms and conditions the user must accept. After agreeing they go to a loading screen which then directs them to the main view. In the screenshot I posted, the view behind the current one in foreground is the splash loading screen.

We will look into adding multiple views scene support throughout the application soon, but right now we have higher priority stuff we need to work on.

"Support multiple windows" is already disabled in the General settings of the app's target. Also I have Enable Multiple Windows set to NO in the info.plist file.

So far nothing has really worked. Basically I want to opt out/disable multiple windows and UIScene/SwiftUI to restore the original behaviour in iOS 10-12. Is this possible in iOS 13 or we have to update it?

Update:

Here is a screenshot of the view debug hierarchy. Left side is iOS 12, right side is on iOS 13. Without adding anything to the Info.plist nor any scene delegate classes or methods, why is it different? Pretty much just ran it in its existing production ready code on Xcode 11.

Best Answer

While you should embrace using scenes when your app is run under iOS 13 and later, you can fully opt out while you still support iOS 12 or earlier.

  • Completely remove the “Application Scene Manifest” entry from Info.plist.

  • If there is a scene delegate class, remove it.

  • If there are any scene related methods in your app delegate, remove those methods.

  • If missing, add the property var window: UIWindow? to your app delegate.

Your app should now only use the app delegate and under iOS 13 it should have the same life cycle as iOS 12.

Note: None of this is specific to Swift or SwiftUI.

Related Topic