A menu bar app written with NSStatusItem and NSMenu can move to SwiftUI’s MenuBarExtra with less code, but plan for two deployment-target jumps: MenuBarExtra needs macOS 13, and SettingsLink, the simple way to open a Settings window from the menu, needs macOS 14. The other change that catches people: MenuBarExtra has no menuNeedsUpdate(_:) moment, so a menu that rebuilds itself on every click has to keep its data current another way. We built the same small utility both ways on our M1 lab Mac with Xcode 26.2 (Swift 6.2.3, macOS 26.2 SDK, macOS 14.0 deployment target); both apps built cleanly, and the shared model’s tests pass.
Why we did this: OneClick QuitAll, our Mac app that lists running apps and quits the ones you do not keep, lives in the menu bar. Every menu bar utility eventually faces the same choice between AppKit and SwiftUI, so we built a small sample that does what QuitAll’s menu does and ported it.
What we built, twice
Both versions share one model and offer the same three things:
- a list of running apps from
NSWorkspace.shared.runningApplications, filtered to regular apps and sorted by name, each with a “keep” checkmark; - a Quit the others command that sends a normal quit (
NSRunningApplication.terminate(), so apps can ask to save) to everything except the kept apps, Finder and itself; - a Settings window.
The AppKit version (StatusItemLab) uses NSStatusBar.system.statusItem(withLength:), an NSMenu with a delegate, and an NSWindow hosting a SwiftUI settings view. The SwiftUI version (MenuBarLab) is a MenuBarExtra scene plus a Settings scene. Treat the code below as a starting point to adapt to your own app.
The menu, side by side

AppKit rebuilds the menu on each click; SwiftUI describes it once and redraws when the model changes.
In AppKit, the status item owns an NSMenu and the delegate refills it in menuNeedsUpdate(_:), which Apple describes as “invoked when a menu is about to be displayed”. Each item needs a target, an action and a state. In SwiftUI the menu is views: Toggle becomes a checkmark item, Divider a separator, Button a command.
@main
struct MenuBarLabApp: App {
@StateObject private var model = RunningAppsModel()
var body: some Scene {
MenuBarExtra("Quit apps", systemImage: "xmark.circle") {
ForEach(model.apps) { app in
Toggle(app.name, isOn: keep(app))
}
Divider()
Button("Quit the others") { model.quitOthers() }
SettingsLink { Text("Settings…") }
.keyboardShortcut(",")
}
.menuBarExtraStyle(.menu)
Settings { SettingsView() }
}
}
What maps one to one, and what does not
Built from Apple’s MenuBarExtra, NSStatusItem and SettingsLink pages, and checked against our two builds:
- Creating the item.
NSStatusBar.system.statusItem(withLength:)plusbutton.imagebecomesMenuBarExtra(_:systemImage:content:)(orimage:for an asset). Apple notes the title “will be used by the accessibility system”. - Menu items.
NSMenuItemwithstatebecomesToggle; a plain item becomesButton;NSMenuItem.separator()becomesDivider(). - Popover instead of a menu. An
NSPopovershown from the status button becomes.menuBarExtraStyle(.window), which Apple describes as “a popover-like window from the menu bar icon”. - Hiding the Dock icon.
NSApp.setActivationPolicy(.accessory)in code becomes theLSUIElementkey, which Apple recommends for apps that only show in the menu bar. In a project with a generated Info.plist, the build settingINFOPLIST_KEY_LSUIElement = YESwrites it; our builtMenuBarLab.appshows"LSUIElement" => 1. - Letting the user remove the item.
NSStatusItem.behaviorbecomes theisInserted:binding: “If the user removes the item from the menu bar, the binding will be set tofalse.” Without that binding, Apple says “an app that only shows in the menu bar will be automatically terminated if the user removes the extra from the menu bar.” - Settings window. A hand-made
NSWindowbecomes aSettingsscene opened bySettingsLink, which “opens the window for the scene or orders it to the front if it is already open”. macOS 14 and later. - Refreshing on open.
menuNeedsUpdate(_:)has no equivalent in theMenuBarExtraAPI. Keep the model current instead (below). - No equivalent: keep AppKit. Right-click menus, a custom view in the menu bar (
NSStatusItem.view), or different actions for click and Option-click: theMenuBarExtrainitializers take a label and content, nothing else.
Where the deployment target bites
We type-checked the SwiftUI app against three deployment targets with the Swift 6.2.3 compiler from Xcode 26.2:

Real compiler output from our M1 lab Mac. At macOS 14.0 the app type-checks with no errors.
If your app still supports macOS 12, either raise the deployment target or keep the AppKit status item until you can. If you only need macOS 13, replace SettingsLink with a button that opens your own settings window.
Keeping the menu current without menuNeedsUpdate
The AppKit menu calls model.refresh() each time it opens. With MenuBarExtra the content is driven by the model, so the model has to update itself. Ours listens to NSWorkspace launch and quit notifications:
@MainActor
public final class RunningAppsModel: ObservableObject {
@Published public private(set) var apps: [AppEntry] = []
@Published public var kept: Set<String> = []
private var observers: [NSObjectProtocol] = []
public init() {
refresh()
let nc = NSWorkspace.shared.notificationCenter
for name in [NSWorkspace.didLaunchApplicationNotification,
NSWorkspace.didTerminateApplicationNotification] {
observers.append(nc.addObserver(forName: name, object: nil, queue: .main) { [weak self] _ in
Task { @MainActor in self?.refresh() }
})
}
}
}
The same model serves both apps, which is the main gain of the port: the logic moves into a package you can test without any UI. Our RunningAppsKit package runs three XCTest cases (the quit list skips the app itself, Finder and kept apps; an empty keep list quits everything else; the live list comes back sorted), and all three pass.
One AppKit trap with the Swift 6.2 compiler
The AppKit version starts with a custom @main entry point that holds the app delegate. Our first attempt failed to compile, even in Swift 5 language mode:
error: call to main actor-isolated initializer 'init()'
in a synchronous nonisolated context
static let delegate = AppDelegate()
AppDelegate is @MainActor, and the static property that creates it was not. Marking the entry type @MainActor fixed it:
@main
@MainActor
enum StatusItemMain {
static let delegate = AppDelegate()
static func main() {
let app = NSApplication.shared
app.setActivationPolicy(.accessory) // no Dock icon
app.delegate = delegate
app.run()
}
}
A SwiftUI App avoids this, since the framework owns the entry point.
Build results

Both apps from one clean Release build each on our M1 lab Mac.
Both apps built in about 6 seconds from empty derived data, with code signing off. The AppKit app came to 164 KB and the SwiftUI app to 180 KB. These are one build of a small sample on one Mac, not a benchmark; for a menu bar utility, size and build time are not a reason to pick either side.
What to check in your own app
- Decide the deployment target first: 13 for
MenuBarExtra, 14 if you wantSettingsLink. - Move the menu’s data into an
ObservableObject(or@Observableon macOS 14) that updates itself, and put it in a package with tests. - Replace
setActivationPolicy(.accessory)withLSUIElementin the Info.plist. - Add an
isInserted:binding if users should be able to hide the item without the app quitting. - Keep AppKit for anything the
MenuBarExtraAPI does not offer: right-click menus, custom status bar views, per-click behaviour.
If your menu bar app also needs to start at login, our port from SMLoginItemSetEnabled to SMAppService covers that side.



