Create a new iOS12 project in Xcode11
Table of Contents
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.
You can easily support sarunw.com by checking out this sponsor.
Offline Transcription: Fast, privacy-focus way to transcribe audio, video, and podcast files. No data leaves your Mac.
@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.
You can easily support sarunw.com by checking out this sponsor.
Offline Transcription: Fast, privacy-focus way to transcribe audio, video, and podcast files. No data leaves your Mac.
Reference
Read more article about Xcode, iOS13, Storyboard, or see all available topic
Enjoy the read?
If you enjoy this article, you can subscribe to the weekly newsletter.
Every Friday, you'll get a quick recap of all articles and tips posted on this site. No strings attached. Unsubscribe anytime.
Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.
If you enjoy my writing, please check out my Patreon https://www.patreon.com/sarunw and become my supporter. Sharing the article is also greatly appreciated.
Become a patron Buy me a coffee Tweet ShareUINavigationBar changes in iOS13
Apple brings a lot of appearance changes in iOS13, and the navigation bar is one of them. Cover everything you should know once you build your app against iOS13 (Xcode11).