---
title: About the app launch sequence
framework: uikit
role: article
role_heading: Article
path: uikit/about-the-app-launch-sequence
---

# About the app launch sequence

Learn the order in which the system executes your code at app launch time.

## Overview

Overview An app launch involves a complex sequence of steps, most of which the system handles automatically. During the launch sequence, UIKit calls methods in your app delegate and scene delegate so you can prepare your app for user interaction and perform any tasks specific to your app’s requirements. The following illustrates the individual steps of this launch sequence, from when the user or system launches your app to when the sequence completes:

The system executes the main() function that Xcode provides in an Objective-C project, or that’s available when you use @main in a Swift project. The main() function calls UIApplicationMain(_:_:_:_:), which creates an instance of UIApplication and your app delegate. UIKit calls the application(_:willFinishLaunchingWithOptions:) method in your app delegate. UIKit performs view controller state restoration, which calls additional methods in your app delegate and view controllers. For more information, see About the UI restoration process. UIKit calls your app delegate’s application(_:didFinishLaunchingWithOptions:) method. After the app launch completes, UIKit prepares a scene to connect to your app, and then calls scene(_:willConnectTo:options:). UIKit may deliver a user activity to this method for you to handle during scene connection. After the launch sequence completes, the system displays your app’s user interface and informs your app or scene delegates when life-cycle events occur. Depending on device conditions, the system may prewarm your app — launch nonrunning app processes to reduce the amount of time a person waits before the app is usable. Prewarming creates your process and loads the libraries your app links against, then suspends your process without allowing any application code to run. After the system prewarms your app’s process, that new process remains in a suspended state until the system wakes your app to continue into the standard launch sequence, or the system ends the prewarmed process to reclaim resources. The system can prewarm your app after a device reboot, and periodically as system conditions allow. Optimize app launch performance To achieve faster startup times, minimize the amount of work your app performs before the call to UIApplicationMain(_:_:_:_:). Running expensive or time-consuming code in methods that the system calls automatically before main(), such as load(), can slow down your app’s launch time. Consider deferring complex initialization tasks to later in the launch sequence. For UI-level tasks — such as configuring your interface or responding to a user activity — defer work to your scene delegate’s scene(_:willConnectTo:options:), sceneWillEnterForeground(_:), or sceneDidBecomeActive(_:) methods. For tasks that aren’t specific to a scene, such as setting up a database layer or configuring app-wide services, use your app delegate’s application(_:willFinishLaunchingWithOptions:) or application(_:didFinishLaunchingWithOptions:) methods. This approach improves launch performance and ensures that initialization occurs when your app has full access to system services. Use MetricKit to accurately measure user-driven launch and resume times and identify opportunities for optimization.

## See Also

### Launch time

- [Performing one-time setup for your app](uikit/performing-one-time-setup-for-your-app.md)
- [Preserving your app’s UI across launches](uikit/preserving-your-app-s-ui-across-launches.md)
