When you create a new project in Xcode 11, it will setup the project for deployment target of iOS 13. If you want to support iOS prior to iOS 13, there are a few steps you need to do.
Change deployment target
Select your app target and go to General tab, under Deployment Info change target to whatever version you want to support.
Practical Sign in with Apple: Learn everything you need to know about Sign in with Apple to be able to integrate it in your existing app or a new one.
@available all the things!!
Since Xcode assume your project will be iOS 13, it created many things that are not compatible with iOS 12, e.g. SceneDelegate.swift
.
So these are files you need to change to make it support old version of iOS.
- SceneDelegate.swift
Add availability attributes to this whole class since thisUIWindowSceneDelegate
is for iOS 13 or greater.
@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
...
}
- AppDelegate.swift
InAppDelegate.swift
there are two newUIApplicationDelegate
methods that we need to Add@available(iOS 13.0, *)
// MARK: UISceneSession Lifecycle
@available(iOS 13.0, *)
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
...
}
@available(iOS 13.0, *)
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
...
}
And the last step is to UIWindow
variable back to AppDelegate
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
}
Conclusion
I don't remember Apple has an option to select deployment target in Xcode before, but since the introduction of iOS 13, as you can see, there is breaking changes. This breaking changes and not so straight forward modification might not be a problem for experienced developers, but I can see it might confuse beginners.
Hopefully, in the future, Apple will ask for the deployment target when creating a new project and prepare files needed for that target.
Reference
Read more article about Xcode, iOS13, Storyboard, or see all available topic