I got this working as following: Using Xcode 26.4, I created a new project from the macOS > App template, choosing Storyboard for the UI. I removed @main from AppDelegate. I added a main.swift file like so: import Cocoa func main() { let delegate = AppDelegate() _ = NSApplication.shared NSApp.delegate = delegate NSApp.run() } main() The difference is that I put the code into a main() function. That function name isn’t special — you could just as easily call it foo() — but it’s important that the code not be at the top level. Top-level code is weird in Swift (-: Having said that, I recommend against doing this. Rather, just call NSApplicationMain. Note that the doc you referenced says “which is functionally similar to”, not “is implement as”. The actual implementation of NSApplicationMain is very different, and by not calling it you’re taking yourself far off the beaten path. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = eskimo + 1 + @ + apple.com
Topic:
Programming Languages
SubTopic:
Swift
Tags: