---
title: "WKApplicationMain(_:_:_:)"
framework: watchkit
role: symbol
role_heading: Function
path: "watchkit/wkapplicationmain(_:_:_:)"
---

# WKApplicationMain(_:_:_:)

Creates the application object and the application delegate, and sets up the app’s event cycle.

## Declaration

```swift
func WKApplicationMain(_ argc: Int32, _ argv: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>, _ applicationDelegateClassName: String?) -> Int32
```

## Parameters

- `argc`: The count of arguments in argv. This is usually the corresponding parameter to main.
- `argv`: A variable list of arguments. This is usually the corresponding parameter to main.
- `applicationDelegateClassName`: The name of the app delegate’s class. This class must subclass doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class and adopt the doc://com.apple.watchkit/documentation/WatchKit/WKApplicationDelegate protocol.

## Return Value

Return Value Even though this function specifies an integer return type, it never returns. When the user exits a watchOS app, the app moves to the background.

## Discussion

Discussion This function instantiates the application object and the specified delegate (if any), and then sets the delegate for the application. It also sets up the main event loop, including the application’s run loop, and begins processing events.

## See Also

### App structure

- [Setting up a watchOS project](watchos-apps/setting-up-a-watchos-project.md)
- [WKApplication](watchkit/wkapplication.md)
- [WKApplicationDelegate](watchkit/wkapplicationdelegate.md)
- [WKExtension](watchkit/wkextension.md)
- [WKExtensionDelegate](watchkit/wkextensiondelegate.md)
- [WKInterfaceDevice](watchkit/wkinterfacedevice.md)
- [WKPrefersNetworkUponForeground](bundleresources/information-property-list/wkprefersnetworkuponforeground.md)
