<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Dispatch",
  "identifier" : "/documentation/Dispatch/dispatchMain()",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Dispatch"
    ],
    "preciseIdentifier" : "c:@F@dispatch_main"
  },
  "title" : "dispatchMain()"
}
-->

# dispatchMain()

Executes blocks submitted to the main queue.

```
func dispatchMain() -> Never
```

## Discussion

This function “parks” the main thread and waits for blocks to be submitted to the main queue. Applications that call <doc://com.apple.documentation/documentation/UIKit/UIApplicationMain(_:_:_:_:)-1yub7> (iOS), <doc://com.apple.documentation/documentation/AppKit/NSApplicationMain(_:_:)> (macOS), or <doc://com.apple.documentation/documentation/CoreFoundation/CFRunLoopRun()> on the main thread must not call [`dispatchMain()`](/documentation/Dispatch/dispatchMain()).

This function never returns.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)
