Article

About the App Launch Sequence

Learn the order in which your custom code is executed at launch time.

Overview

Launching an app involves a complex sequence of steps, most of which UIKit handles automatically. During the launch sequence, UIKit calls methods of your app delegate so that you can perform custom tasks. Figure 1 illustrates the sequence of steps that occur from the time the app is launched until it is considered initialized.

Figure 1

The app launch and initialization sequence

When an app launches, it loads its main UI file, asks the app delegate to initialize the app's data structures, and restores any previous interface state.

  1. The app is launched, either explicitly by the user or implicitly by the system.

  2. The Xcode-provided main function calls UIKit's UIApplicationMain(_:_:_:_:) function.

  3. The UIApplicationMain(_:_:_:_:) function creates the UIApplication object and your app delegate.

  4. UIKit loads your app's default interface from the main storyboard or nib file.

  5. UIKit calls your app delegate's application(_:willFinishLaunchingWithOptions:) method.

  6. UIKit performs state restoration, which calls additional methods of your app delegate and view controllers.

  7. UIKit calls your app delegate's application(_:didFinishLaunchingWithOptions:) method .

When initialization is complete, the system uses either your scene delegates or app delegate to display your UI and manage the life cycle for your app.

See Also

Launch Time

Performing One-Time Setup for Your App

Ensure that your app environment is properly configured.

Preserving Your App's UI Across Launches

Return your app to its previous state after it is terminated by the system.