Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save munho/97a16ce3585b798e46f79ffd7e94401d to your computer and use it in GitHub Desktop.
Save munho/97a16ce3585b798e46f79ffd7e94401d to your computer and use it in GitHub Desktop.
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
/// 1. Capture the scene
guard let windowScene = (scene as? UIWindowScene) else { return }
/// 2. Create a new UIWindow using the windowScene constructor which takes in a window scene.
let window = UIWindow(windowScene: windowScene)
/// 3. Create a view hierarchy programmatically
let viewController = ArticleListViewController()
let navigation = UINavigationController(rootViewController: viewController)
/// 4. Set the root view controller of the window with your view controller
window.rootViewController = navigation
/// 5. Set the window and call makeKeyAndVisible()
self.window = window
window.makeKeyAndVisible()
}
@munho
Copy link
Author

munho commented Dec 28, 2023

[iOS] AppDelegate와 SceneDelegate

Deployment Target이 iOS 13 미만인 상황에서는?

  1. iOS13에서 새로 생긴 SceneDelegate.swift 파일 삭제
  2. iOS13에서 AppDelegate에 추가된 UISceneSession과 관련된 두 매소드 삭제
// 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<UISceneSession>) {
    // 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.
    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
  1. iOS13에서 SceneDelegate로 옮겨진 window 프로퍼티를 AppDelegate로 다시 옮기기
var window: UIWindow?
  1. info.plist에서 Scene과 관련된 Manifest인 Application Scene Manifest 삭제

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment