If you create a new app in Xcode 11 and try to run it on an iOS 12 device or lower, you volition go a bunch of errors :

errors

Notice that most of these errors are related to the UIScene form and the SceneDelegate.swift file, these are related to the multi-window characteristic introduced in iOS 13, which allows multiple windows of an app to exist opened in iPad. As iOS 12 and earlier don't take these feature, we will get these error messages when trying to compile.

We will try to resolve these errors step by step in this article.

You can salvage the hassle by setting deployment target to iOS 13 and to a higher place, and ditch back up for iOS 12 and below 😈. But keep in mind that half of the iOS devices in apportionment are not using iOS 13 as of mid October 2019, according to Apple'due south report :

iOS Percentage

If y'all are dropping support for iOS 12 and below, you are denying one-half of the iOS users to use your app! 😱

Update deployment target

If you lot oasis't already, change the deployment target to the lowest iOS version you want to support, select the project name and then select your app target, cull Full general and change the version in Deployment Info.

change deployment target

@available out the SceneDelegate.swift

As the SceneDelegate grade is only available on iOS 13 and in a higher place, nosotros have to tell the compiler to only include the class for iOS 13 and above. To practise this, nosotros will add this line "@available(iOS 13.0, *)" correct above the  SceneDelegate class announcement like this :

          import UIKit  @available(iOS 13.0, *) class SceneDelegate: UIResponder, UIWindowSceneDelegate { //... }                  

@available out some methods in AppDelegate.swift

Adjacent, at that place are two new methods added in AppDelegate.swift, which but supports iOS 13 and above. We will add the aforementioned @available(iOS thirteen.0, *) on top of them as well :

          // AppDelegate.swift  @available(iOS 13.0, *) func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {     // Chosen when a new scene session is being created.     // Use this method to select a configuration to create the new scene with.     render UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) }  @available(iOS 13.0, *) func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {     // Called when the user discards a scene session.     // If any sessions were discarded while the application was not running, this will be chosen presently later application:didFinishLaunchingWithOptions.     // Apply this method to release any resources that were specific to the discarded scenes, equally they volition not return. }                  

Add together dorsum the window to AppDelegate

If you build and run your app at present, you will get a dark black screen 😱, because there's no UIWindow initialized.

In iOS 12 and older, there'due south always a var window: UIWindow? variable located at the height of AppDelegate.swft. iOS xiii has moved this variable to SceneDelegate.swift, and at present we are going to add back this variable to AppDelegate.

          import UIKit  @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {           var window: UIWindow?        // ... }                  

Now Build and run your app on an iOS 12 devices, and it works! 🥳

I guess Apple tree really wants iOS developers to prefer and focus on iOS 13, to the extent that they don't listen breaking back up for iOS 12 and older with default settings in Xcode.

If you are lazy to do these step manually every fourth dimension, you can also download Xcode 10.3 in the Apple tree's developer download portal (require sign in with your Apple ID), create a new Xcode project using it, and then edit it using Xcode xi.