말 그대로 앱이 켜지고 꺼지는 그 과정을 말한다.
정확히는 앱의 실행/종료 및 앱이 Foreground/Background 상태에 있을 때,
시스템이 발생시키는 event에 의해 앱의 상태가 전환되는 일련의 과정을 뜻한다.
이걸 알아야 앱의 상태가 변경되거나 앱의 특정 시점에 맞게 동작을 수행시킬 수 있다.
앱의 라이프사이클은 AppDelegate와 SceneDelegate가 관리한다.
그래서 앱의 실행과 종료 (Not Running / Suspend)는 AppDelegate가,
Foreground / Background는 SceneDelegate가 담당한다.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
sleep(2)
return true
}
sleep(2) 를 하면 런치스크린이 무조건 2초 동안은 켜져 있는다.func applicationDidEnterBackground(_ application: UIApplication) {
<#code#>
}
func applicationWillEnterForeground(_ application: UIApplication) {
<#code#>
}
SceneDelegate에서 Scene이 새롭게 생성되고 종료되는 트리거를 AppDelegate에게 알려줌으로써,
AppDelegate가 앱의 생성과 종료 시점을 통제할 수 있다.
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)
}
// MARK: UISceneSession Lifecycle
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
}