From 170800b53356f63fed1322ff3f463a7ff8f91604 Mon Sep 17 00:00:00 2001 From: clarknt <24315769+clarknt@users.noreply.github.com> Date: Tue, 19 Nov 2019 20:31:31 -0500 Subject: [PATCH] Add iOS 12 backwards compatibility --- .../Coordinators.xcodeproj/project.pbxproj | 2 ++ .../Coordinators/AppDelegate.swift | 24 +++++++++++++++++-- .../Coordinators/SceneDelegate.swift | 1 + README.md | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/01-Coordinators/Coordinators.xcodeproj/project.pbxproj b/01-Coordinators/Coordinators.xcodeproj/project.pbxproj index d09dc79..2419274 100644 --- a/01-Coordinators/Coordinators.xcodeproj/project.pbxproj +++ b/01-Coordinators/Coordinators.xcodeproj/project.pbxproj @@ -322,6 +322,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; INFOPLIST_FILE = Coordinators/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -339,6 +340,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; INFOPLIST_FILE = Coordinators/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/01-Coordinators/Coordinators/AppDelegate.swift b/01-Coordinators/Coordinators/AppDelegate.swift index 3bb2ec3..295d651 100644 --- a/01-Coordinators/Coordinators/AppDelegate.swift +++ b/01-Coordinators/Coordinators/AppDelegate.swift @@ -10,22 +10,42 @@ import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { - - + + var window: UIWindow? + var coordinator: MainCoordinator? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. + + if #available(iOS 13, *) { } else { + // create the main navigation controller to be used for our app + let navController = UINavigationController() + + // send that into our coordinator so that it can display view controllers + coordinator = MainCoordinator(navigationController: navController) + + // tell the coordinator to take over control + coordinator?.start() + + // create a basic UIWindow and activate it + window = UIWindow(frame: UIScreen.main.bounds) + window?.rootViewController = navController + window?.makeKeyAndVisible() + } + return true } // MARK: UISceneSession Lifecycle + @available(iOS 13.0, *) func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { // Called when a new scene session is being created. // Use this method to select a configuration to create the new scene with. return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } + @available(iOS 13.0, *) func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { // Called when the user discards a scene session. // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. diff --git a/01-Coordinators/Coordinators/SceneDelegate.swift b/01-Coordinators/Coordinators/SceneDelegate.swift index 849decc..5b8b487 100644 --- a/01-Coordinators/Coordinators/SceneDelegate.swift +++ b/01-Coordinators/Coordinators/SceneDelegate.swift @@ -8,6 +8,7 @@ import UIKit +@available(iOS 13.0, *) class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? diff --git a/README.md b/README.md index 08e23ad..11451b4 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Template implementation of [Soroush Khanlou](http://khanlou.com)'s Coordinator d - [How to use the coordinator pattern in iOS apps](https://www.hackingwithswift.com/articles/71/how-to-use-the-coordinator-pattern-in-ios-apps) - [Advanced coordinators in iOS](https://www.hackingwithswift.com/articles/175/advanced-coordinator-pattern-tutorial-ios) -Requirements: iOS 13 and XCode 11. +Compatibility tested with XCode 11, iOS 12 and iOS 13.