Making an iOS 13 project work in iOS 12

When creating a new project in XCode 11.1, that project will only support iOS 13. This post will show how to add iOS 12 (and earlier) support.

Note that XCode 11.1 has updated its new project templates. There’s now an option called “User Interface” that allows the choice of “SwiftUI” and “Storyboard”. SwiftUI is only supported in iOS 13, so any new projects that also need to support iOS 12 should use Storyboard.

Once the project is created, it will compile and run in any of the provided simulators. Note that the list only includes iOS 13 devices.

To make iOS 12 devices appear, go to the project settings, under General -> Deployment Info -> Target. Choose whatever earlier OS you’d like to support (e.g. 12.4).

Now the device list will show both iOS 12 and 13 devices.

Choose an iOS 12 device and try to run the project. XCode will present a number of compilation errors, including:

  • ‘UIScene’ is only available in iOS 13.0 or newer
  • ‘UISceneSession’ is only available in iOS 13.0 or newer
  • ‘ConnectionOptions’ is only available in iOS 13.0 or newer

To fix these:

1) Delete the SceneDelegate.swift file entirely
2) Replace the contents of AppDelegate with the following

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {  

   let storyboard = UIStoryboard(name: "Main", bundle: nil)
   let vc = storyboard.instantiateInitialViewController() window = UIWindow(frame: UIScreen.main.bounds)
   window?.rootViewController = vc window?.makeKeyAndVisible()
   return true
}

The app should now compile and run. Depending on the template chosen, you may get a runtime error related to the scene manifest. To fix this, open Info.plist and delete the entry named “Application Scene Manifest”.

Now that you’ve removed the iOS 13 dependent code and configuration, your app should now run in devices on earlier versions.

Leave a Reply

Your email address will not be published.