I’m running macOS 15.7 with Xcode 26.2, and I’m trying to learn the basics of AppKit.
I’m fully aware that AppKit is considered a legacy / “old” technology and that Apple clearly does not promote it out of the box anymore. This is especially visible in recent versions of Xcode, where you can no longer create a macOS App template without Storyboards or SwiftUI.
That said, AppKit is still widely used under the hood, so I think it’s reasonable to at least understand its fundamentals.
Here’s the problem I’m facing.
I create a standard macOS App project using the Xcode template (AppKit App Delegate). Then I:
delete Main.storyboard
remove all storyboard references from Info.plist
try to create the window manually in applicationDidFinishLaunching
At this point, the project builds, but the app either:
does not show any window, or
behaves as if it were not a proper GUI app
While debugging, it looks like Xcode / Swift is treating my target more like a dylib / wrapper than a normal .app bundle (at least judging by runtime behavior and the lack of a proper AppKit lifecycle).
While searching for answers, I found this article:
https://ashidiqi.com/blog/how-to-setup-xcode-project-programmatically-with-appkit/
The author claims that in this scenario you must not use the @main attribute and instead need a main.swift file that manually calls NSApplicationMain.
However, the article also mentions that Xcode shows the error:
'main' attribute cannot be used in a module that contains top-level code
The confusing part is that I do not have any top-level code in my project when using @main.
At the same time, when I ask an LLM for clarification, it tells me that:
@main does not require a storyboard
removing a storyboard does not force you to switch to main.swift
@main should work fine for a fully programmatic AppKit app
So I’m left with two concrete questions:
What is the correct, modern answer here? When building a fully programmatic AppKit app (no storyboard, no SwiftUI), do you actually need main.swift, or is @main still fully supported and correct?
Is there any supported or recommended way in modern Xcode to get a “clean” AppKit app template without a storyboard? Either via project settings, templates, or some documented workflow — without having to fight the build system or end up with a half-broken target.
I’m not trying to fight Apple’s direction here — I just want to understand the correct way to work with AppKit in 2025, even if it’s not the preferred path anymore.
Thanks in advance for any clarification.
Selecting any option will automatically load the page