Creates the application object and the application delegate and sets up the event cycle.


func UIApplicationMain(_ argc: Int32, _ argv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>, _ principalClassName: String?, _ delegateClassName: String?) -> Int32



The count of arguments in argv; this usually is the corresponding parameter to main.


A variable list of arguments; this usually is the corresponding parameter to main.


The name of the UIApplication class or subclass. If you specify nil, UIApplication is assumed.


The name of the class from which the application delegate is instantiated. If principalClassName designates a subclass of UIApplication, you may designate the subclass as the delegate; the subclass instance receives the application-delegate messages. Specify nil if you load the delegate object from your application’s main nib file.

Return Value

Even though an integer return type is specified, this function never returns. When users exits an iOS app by pressing the Home button, the application moves to the background.


This function instantiates the application object from the principal class and instantiates the delegate (if any) from the given class and sets the delegate for the application. It also sets up the main event loop, including the application’s run loop, and begins processing events. If the application’s Info.plist file specifies a main nib file to be loaded, by including the NSMainNibFile key and a valid nib file name for the value, this function loads that nib file.

Despite the declared return type, this function never returns. For more information on how this function behaves, see “Expected App Behaviors” in App Programming Guide for iOS.

See Also


Managing Your App's Life Cycle

Understand how the app delegate manages your app's high-level behavior.

class UIApplication

The centralized point of control and coordination for apps running in iOS.

protocol UIApplicationDelegate

A set of methods that are called by the singleton UIApplication object in response to important events in the lifetime of your app.

Allowing Apps and Websites to Link to Your Content

Use universal links to link to content within your app and share data securely.