/desktop-apps-macos-linux:desktop-macos-platformfrom desktop-apps-macos-linux
Covers macOS native app development: SwiftUI vs AppKit, Darwin stack, bundles, run loop/GCD, XPC, Apple silicon, Rosetta, universal binaries, Liquid Glass, Mac Catalyst, Swift 6 concurrency, and persistence (SwiftData, Core Data, GRDB).
Ships in desktop-apps-macos-linux. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Part 1 of 5 of the Desktop Application Programming — macOS & Linux reference (plugin
desktop-apps-macos-linux), covering §0–§3. Sibling skills:desktop-linux-platform(§4–§6),desktop-cross-platform-and-architecture(§7–§9),desktop-packaging-security-and-testing(§10–§13),desktop-reference(§14–§20). Section numbers are shared across the set; a reference written as §N →skillpoints into that sibling skill.Currency: Verified August 2026. See §18 →
desktop-referencefor the currency snapshot and what goes stale first.
How to read this. Reference, not tutorial. Sections are independent. Three markers:
- [UNIVERSAL] — true of desktop software regardless of platform or toolkit.
- [PLATFORM] — specific to macOS or a particular Linux stack. Verify against current docs.
- [CONTESTED] — competent engineers disagree. Both cases given; don't adjudicate for the reader.
⚠️ GOTCHA boxes mark the failure modes that actually cost people days.
The single most important framing in this document: macOS is one platform with one vendor, one HIG, and one blessed path. Linux is not a platform — it is a family of overlapping conventions (freedesktop specs), two dominant toolkits, two display protocols, three packaging formats, and a dozen desktop environments. Advice that treats them symmetrically is wrong. Almost every difficulty in cross-platform desktop work traces back to this asymmetry.
| If the answer to this is yes... | ...then |
|---|---|
| macOS-only, deep OS integration, sold on the Mac App Store | SwiftUI + AppKit |
| macOS + iOS from one codebase | SwiftUI (multiplatform target, not Catalyst) |
| Linux-first, GNOME-native feel, will ship on Flathub | GTK4 + libadwaita |
| Linux-first, KDE-native, or Linux+Windows+macOS with one native-ish toolkit | Qt 6 |
| Team is web developers; you already have a web app; deadline dominates | Electron |
| Team can take on Rust; bundle size / memory matter; want a small attack surface | Tauri 2 |
| Existing .NET/WPF codebase and skills; need Linux | Avalonia |
| Existing Kotlin/Android codebase; JVM shop | Compose Multiplatform |
| Pixel-identical custom UI on every OS, mobile too, don't care about native feel | Flutter |
| It's a developer tool / internal utility; native feel is irrelevant | Anything. Ship it. |
[UNIVERSAL] The framework decision is downstream of two questions people skip:
A. Pure native, per platform — two codebases, best feel, highest cost
B. Native UI + shared core — Rust/C++/Go core, SwiftUI on Mac, GTK/Qt on Linux
(the "right" answer for serious cross-platform apps)
C. Single cross-platform toolkit — Qt / Flutter / Avalonia / Compose. One UI, everywhere.
D. Web UI in a shell — Electron / Tauri. One UI, everywhere, web tech.
B is underrated. Ghostty (Zig core + SwiftUI on macOS + GTK4 on Linux), 1Password (Rust core), Signal, and many others use it. The core is testable, portable, and performance-critical; the UI is thin and idiomatic per platform. The cost is that you write the UI twice — but the UI is usually the smaller half of a serious application, and it's the half where "twice" buys you the most.
| Asked about... | Go to |
|---|---|
| Bundles, launchd, run loops, Darwin, XPC | §1 |
| SwiftUI, AppKit, NSViewRepresentable, Liquid Glass, menus, windows | §2 |
| Swift concurrency, @MainActor, SwiftData/Core Data | §3 |
| D-Bus, systemd user units, XDG specs, PipeWire, desktop files | §4 → desktop-linux-platform |
| GTK4, libadwaita, Qt6, QML, toolkit choice on Linux | §5 → desktop-linux-platform |
| Wayland, X11, XWayland, compositors, protocols | §6 → desktop-linux-platform |
| Electron, Tauri, Flutter, Avalonia, Compose, Rust GUI | §7 → desktop-cross-platform-and-architecture |
| MVVM, state management, undo, documents, IPC, threading | §8 → desktop-cross-platform-and-architecture |
| Windows, keyboard, drag & drop, HiDPI, dark mode, i18n, a11y | §9 → desktop-cross-platform-and-architecture |
| Notarization, DMG, Flatpak, Snap, AppImage, .deb/.rpm, AppStream | §10 → desktop-packaging-security-and-testing |
| Sparkle, auto-update, delta updates, rollout | §11 → desktop-packaging-security-and-testing |
| TCC, entitlements, hardened runtime, portals, Electron security | §12 → desktop-packaging-security-and-testing |
| UI testing, profiling, Instruments, sysprof, CI | §13 → desktop-packaging-security-and-testing |
| "Don't do this" | §14 → desktop-reference |
| "Which is better, X or Y?" | §15 → desktop-reference (contested) |
| Books, docs, HIGs, authorities | §16 → desktop-reference |
| Famous failures and lessons | §17 → desktop-reference |
| "Is this still current?" | §18 → desktop-reference |
┌──────────────────────────────────────────────────┐
│ Your app: SwiftUI / AppKit / Catalyst / 3rd-party│
├──────────────────────────────────────────────────┤
│ App frameworks: AppKit, SwiftUI, UIKit(Catalyst) │
├──────────────────────────────────────────────────┤
│ Media/graphics: Core Animation, Metal, Core Image,│
│ AVFoundation, Core Text │
├──────────────────────────────────────────────────┤
│ Core Services: Foundation, Core Foundation, GCD, │
│ Core Data, Network.framework, XPC │
├──────────────────────────────────────────────────┤
│ Darwin: XNU kernel (Mach + BSD), launchd, dyld, │
│ APFS, Sandbox (Seatbelt), TCC, AMFI, SIP │
└──────────────────────────────────────────────────┘
Things that matter and are non-obvious:
LaunchAgents run per-user in the GUI session (~/Library/LaunchAgents,
/Library/LaunchAgents). LaunchDaemons run as root, system-wide, with no GUI
session (/Library/LaunchDaemons).SMAppService (macOS 13+) to register login items and
helpers from inside the app bundle, rather than dropping plists into
~/Library/LaunchAgents. The user then manages them in System Settings → General →
Login Items, which is what they expect.DYLD_* environment variables are ignored for hardened-runtime and
SIP-protected processes — which is exactly why your DYLD_LIBRARY_PATH trick works in
development and fails in the notarized build./System, /usr (except /usr/local),
and /bin immutable even to root. Never write outside /usr/local, /opt, or the
app's own container.MyApp.app/
└── Contents/
├── Info.plist ← identity, version, doc types, URL schemes, usage strings
├── MacOS/
│ └── MyApp ← the actual executable (CFBundleExecutable)
├── Resources/
│ ├── Assets.car ← compiled asset catalog (icons, images, colors)
│ ├── en.lproj/ ← localized strings, per language
│ └── de.lproj/
├── Frameworks/ ← embedded .framework and .dylib — MUST be signed
├── PlugIns/ ← app extensions
├── XPCServices/ ← XPC helpers
├── Library/
│ └── LoginItems/ ← helper apps registered via SMAppService
├── _CodeSignature/ ← signature over the whole bundle
└── embedded.provisionprofile (App Store / some entitlements)
Info.plist keys you will actually need:
| Key | Purpose |
|---|---|
CFBundleIdentifier | Reverse-DNS identity. Immutable in practice — changing it orphans user data, keychain items, and the App Store record. |
CFBundleShortVersionString | Marketing version ("2.1.0") — what users see |
CFBundleVersion | Build number — must monotonically increase per upload |
LSMinimumSystemVersion | Minimum macOS |
CFBundleDocumentTypes / UTExportedTypeDeclarations | File type ownership + custom UTIs |
CFBundleURLTypes | Custom URL schemes (myapp://) |
NS*UsageDescription | Required privacy strings — missing one = instant crash on first use of that API |
LSUIElement | true = menu-bar-only app, no Dock icon |
LSApplicationCategoryType | Required for the App Store |
ITSAppUsesNonExemptEncryption | Saves you an export-compliance dialog on every upload |
⚠️ GOTCHA — missing usage strings crash, they don't warn. Calling an API guarded by TCC (camera, microphone, contacts, calendar, photos, Downloads/Documents/Desktop, screen recording, Automation/AppleScript) without the corresponding
NSCameraUsageDescription-style key in Info.plist terminates the process immediately. This looks like a random crash on a user's machine and is instant in the debugger. Write the strings as user-facing sentences — the App Store rejects vague ones.
Where app data goes [PLATFORM]:
| Content | Sandboxed path | Non-sandboxed |
|---|---|---|
| User-visible documents | ~/Documents via user selection | same |
| App support / databases | ~/Library/Containers/<id>/Data/Library/Application Support/<id> | ~/Library/Application Support/<id> |
| Caches (deletable) | .../Library/Caches/<id> | ~/Library/Caches/<id> |
| Preferences | UserDefaults → .../Library/Preferences/<id>.plist | same |
| Logs | .../Library/Logs/<id> | ~/Library/Logs/<id> |
Use FileManager.default.url(for: .applicationSupportDirectory, in: .userDomainMask, ...)
and never hardcode paths — sandboxing silently redirects them, and hardcoded paths are the
#1 reason an app breaks when you enable the sandbox.
[PLATFORM, but the concept is UNIVERSAL] All UI work happens on the main thread.
On macOS the main thread runs an NSRunLoop/CFRunLoop that dispatches events, timers,
and sources. Touching NSView/NSWindow — or SwiftUI state that a view reads — from any
other thread is undefined behaviour that manifests as corrupted rendering or a crash in
unrelated code minutes later.
DispatchQueue): DispatchQueue.main is the UI queue. Background work goes on
.global(qos:) or a private serial queue. QoS classes (.userInteractive,
.userInitiated, .utility, .background) affect scheduling priority and
thermal/energy behaviour — mislabeling background work as .userInitiated is a real
battery cost.async/await, actors, @MainActor) is the modern layer over
this, and as of Swift 6 the compiler enforces the main-thread rule (§3.2).DispatchQueue.concurrentPerform and unbounded
DispatchQueue.global().async can blow past the thread limit and deadlock. Bound your
concurrency explicitly (semaphore, TaskGroup with a limit, or a serial queue).XPC is macOS's IPC mechanism, with lifecycle management by launchd. Use it for:
SMJobBless-style root helpers (modern: SMAppService.daemon)
for the rare operation that truly needs root. Verify the client's code signature in
the helper — an unauthenticated root helper is a local privilege-escalation
vulnerability, and this has shipped in real products repeatedly.// Modern XPC with NSXPCConnection, plus the security check that people omit
let connection = NSXPCConnection(serviceName: "com.example.MyApp.ParserService")
connection.remoteObjectInterface = NSXPCInterface(with: ParsingProtocol.self)
connection.resume()
let proxy = connection.remoteObjectProxyWithErrorHandler { error in
// Service crashed or was killed — degrade gracefully, don't crash the app
log.error("XPC failed: \(error)")
} as? ParsingProtocol
arm64 + x86_64) via lipo/Xcode until you drop Intel.
macOS 26 Tahoe is the last macOS to support Intel Macs — from macOS 27, Apple
silicon only. That changes the calculus for new products: an arm64-only build is now
defensible for apps requiring macOS 27+.MTLStorageMode.shared is usually right.[CONTESTED, and the most consequential macOS decision.] The honest summary that experienced Mac developers converge on: almost nobody starts a new Mac app in pure AppKit anymore, and almost no serious Mac app is pure SwiftUI. The real skill is knowing where the seam goes. Apple's own guidance (WWDC26 "Use SwiftUI with AppKit and UIKit") is explicitly incremental: start new scenes in SwiftUI, keep existing AppKit, and there is no expectation that an app becomes entirely SwiftUI.
Case for SwiftUI on macOS:
@Observable (the Observation framework) removed most of the ObservableObject
boilerplate and its over-invalidation problems.Case for AppKit (still, in 2026):
NSTableView/NSOutlineView with cell reuse still beat SwiftUI
List/Table for tens of thousands of rows with complex cells. This is the single most
commonly cited gap.NSWindow subclassing behaviours.NSTextView/TextKit 2 is a full text system; SwiftUI's TextEditor is not
in the same category. Any editor, IDE, or writing app will use it.The pragmatic architecture most shipping apps use:
SwiftUI → app structure (App/Scene), settings, sidebars, inspectors, simple lists,
anything form-shaped
AppKit → the one hard view (the editor, the canvas, the giant table), embedded via
NSViewRepresentable / NSViewControllerRepresentable
Shared → @Observable model layer that both read
The parts of SwiftUI that only matter on the Mac, which iOS-shaped tutorials skip:
@main
struct MyApp: App {
@State private var model = AppModel() // @Observable, @MainActor
var body: some Scene {
// A document-based app gets New/Open/Save/Revert/Versions for free
DocumentGroup(newDocument: MyDocument()) { file in
EditorView(document: file.$document)
}
.commands {
// Menu bar customization — Mac-only, and where most Mac apps live
CommandGroup(replacing: .newItem) {
Button("New Project…") { model.newProject() }
.keyboardShortcut("n", modifiers: [.command, .shift])
}
CommandMenu("Analyze") {
Button("Run") { model.run() }.keyboardShortcut("r")
Divider()
Button("Clear Results") { model.clear() }
.disabled(model.results.isEmpty) // menu items MUST disable
}
}
// Settings scene → gets the standard ⌘, shortcut and window chrome
Settings { SettingsView().frame(width: 520) }
// A secondary utility window, openable via openWindow(id:)
Window("Activity", id: "activity") { ActivityView() }
.defaultSize(width: 400, height: 300)
.keyboardShortcut("0", modifiers: .command)
// Menu bar extra — the Mac's status-item idiom
MenuBarExtra("Status", systemImage: "waveform") {
StatusMenu()
}
.menuBarExtraStyle(.window) // .menu for a plain menu, .window for a popover
}
}
// Standard Mac three-column layout
struct RootView: View {
var body: some View {
NavigationSplitView {
Sidebar()
} content: {
ItemList()
} detail: {
DetailView()
}
.toolbar { /* ... */ }
.navigationSplitViewStyle(.balanced)
}
}
Mac-specific view modifiers worth knowing: .focusedSceneValue (drive menu enablement
from the focused window's state — this is how you make menu items correctly gray out),
.onKeyPress, .contextMenu, .draggable/.dropDestination, .fileExporter/
.fileImporter (they route through the sandbox correctly), .help() (tooltips),
.windowResizability, .defaultPosition, .presentedWindowToolbarStyle.
// Wrapping AppKit inside SwiftUI: the 90% case
struct TextEditorView: NSViewRepresentable {
@Binding var text: String
func makeNSView(context: Context) -> NSScrollView {
let scroll = NSTextView.scrollableTextView()
let tv = scroll.documentView as! NSTextView
tv.delegate = context.coordinator
tv.isRichText = false
tv.font = .monospacedSystemFont(ofSize: 13, weight: .regular)
return scroll
}
func updateNSView(_ scroll: NSScrollView, context: Context) {
guard let tv = scroll.documentView as? NSTextView else { return }
// ⚠️ Guard against feedback loops: only write if actually different,
// or every keystroke round-trips and the cursor jumps to the end.
if tv.string != text { tv.string = text }
}
func makeCoordinator() -> Coordinator { Coordinator(self) }
final class Coordinator: NSObject, NSTextViewDelegate {
let parent: TextEditorView
init(_ p: TextEditorView) { parent = p }
func textDidChange(_ n: Notification) {
guard let tv = n.object as? NSTextView else { return }
parent.text = tv.string
}
}
}
// Wrapping SwiftUI inside AppKit: the incremental-adoption direction
let host = NSHostingController(rootView: InspectorView(model: model))
splitViewController.addSplitViewItem(NSSplitViewItem(viewController: host))
⚠️ GOTCHA — the
updateNSViewfeedback loop. This is the interop bug. SwiftUI callsupdateNSViewwhenever any observed state changes; if you unconditionally write to the AppKit view, and the AppKit view's delegate writes back to the binding, you get an infinite loop or (more insidiously) a cursor that resets to position 0 on every keystroke. Always compare before assigning, and consider a "programmatic change" flag.
⚠️ GOTCHA — sizing.
NSViewRepresentabledoesn't automatically communicate an intrinsic size to SwiftUI's layout. SetintrinsicContentSizeon the NSView, or use.frame()/sizeThatFitsexplicitly, or you'll get a zero-height view and conclude the wrapper is broken.
macOS 26 introduced Liquid Glass, the biggest visual change since 2013 — a translucent, light-refracting material applied to toolbars, sidebars, menu bar, Dock, window controls, sheets, and popovers. What developers need to know:
.glassEffect(), GlassEffectContainer, and glassEffectID for
morphing between glass elements.[CONTESTED] Whether to adopt aggressively: proponents argue apps that don't adapt will
look broken beside system apps; skeptics note the material is expensive to render, hurts
legibility when misapplied, and that Apple's own first-year implementations drew
substantial criticism. The defensible middle: adopt the system chrome (free), use
semantic colors and system materials rather than hardcoded palettes, and be conservative
about applying .glassEffect() to your own content surfaces.
Catalyst runs a UIKit iPad app on the Mac. Its purpose is porting an existing iPad app, and that's the only case where it's the right call. For a new multiplatform product, a SwiftUI multiplatform target produces a better Mac app for the same effort. Note also that Apple silicon Macs can simply run unmodified iPad apps, which removes much of Catalyst's original motivation. Catalyst apps consistently read as "not quite a Mac app" to Mac users — wrong menu structure, wrong keyboard behaviour, wrong window resizing.
@Observable (Observation framework) replaced ObservableObject/@Published for
most purposes: finer-grained invalidation (SwiftUI only re-renders views that read the
properties that actually changed), less boilerplate, no objectWillChange plumbing.struct for models, final class when you need identity,
actor for shared mutable state.Swift 6 makes data-race safety a compile-time guarantee: warnings in Swift 5 mode become errors. Core concepts:
| Concept | Meaning |
|---|---|
Sendable | Marker protocol: values of this type can safely cross concurrency domains. Structs of Sendable members get it synthesized; classes only if immutable (final + all let) or internally synchronized. |
actor | Reference type with automatic mutual exclusion on its state. |
@MainActor | Global actor for UI. Everything touching views/view models belongs here. |
nonisolated | Opt a member out of its actor's isolation (must not touch isolated state). |
nonisolated(unsafe) | "Trust me." Last resort; document why. |
@preconcurrency | Import a not-yet-audited module without drowning in errors. |
// The canonical shapes.
@MainActor @Observable
final class DocumentViewModel { // UI state — main actor
var items: [Item] = []
var isLoading = false
private let store: ItemStore // an actor
func refresh() async {
isLoading = true
defer { isLoading = false }
items = await store.fetchAll() // compiler inserts the hop
}
}
actor ItemStore { // shared mutable state — isolated
private var cache: [UUID: Item] = [:]
func fetchAll() -> [Item] { Array(cache.values) }
func insert(_ item: Item) { cache[item.id] = item }
}
struct Item: Sendable, Identifiable { // crosses boundaries — must be Sendable
let id: UUID
var title: String
}
[IMPORTANT, and recent] Swift 6.2 changed the ergonomics substantially. The
"approachable concurrency" work (SWIFT_APPROACHABLE_CONCURRENCY = YES, on by default for
new Xcode 26 projects) inverts the default: code is main-actor-isolated unless you say
otherwise, and nonisolated async functions run on the caller's actor rather than
hopping. @concurrent is the explicit escape hatch for pushing CPU-heavy work
(decoding, image processing) off the main actor.
[CONTESTED] Whether this is an improvement: proponents say the old model buried the
signal in a wall of Sendable errors and drove people to slap @unchecked Sendable on
everything, so a safe-by-default model that's easy to use correctly is a net win.
Critics — notably the "Swift Concurrency is a Mess in 2026" line of argument — say the
repeated model changes eroded trust, and that main-actor-by-default hides main-thread
bottlenecks from developers who never learn to move work off it. Both observations are
accurate; which dominates depends on team seniority.
Migration strategy that works (from teams who've done it on 50K+ LOC):
@MainActor on view models and UI-adjacent classes → Sendable
on value types that cross boundaries → actor for shared mutable services → globals
last (static let + Sendable, or @MainActor, or as a last resort
nonisolated(unsafe) with a comment explaining the invariant).⚠️ GOTCHA — the singleton.
static var sharedis non-isolated global mutable state and is an error in Swift 6. Fix withstatic let+Sendable, or@MainActor static let, or convert the type to anactor. Do not reach fornonisolated(unsafe)first.
| Option | Use when | Watch out for |
|---|---|---|
| UserDefaults | Small preferences, window state | Not for data. Not synchronized across processes reliably. |
| SwiftData | New apps, macOS 14+/iOS 17+, SwiftUI-shaped models | Younger; heavyweight/custom migrations and some CloudKit sync modes still weak; measurable overhead at 10K+ rows |
| Core Data | Existing apps, complex object graphs, 15+ entities, batch ops, older OS support | Verbose; concurrency model fights modern Swift; .xcdatamodeld is an Xcode-bound artifact |
| GRDB / SQLiteData | Data-heavy apps, you want SQL and control, fastest reads/bulk writes | More glue code for SwiftUI reactivity; no free CloudKit |
| Plain files (JSON/plist/SQLite) | Document-based apps, simple state | You own migration and atomicity |
[CONTESTED] SwiftData vs Core Data in 2026. SwiftData is built on Core Data's storage engine and has been stable across three major OS releases; for new apps with SwiftUI it's the productivity default. But real teams still choose Core Data for complex models — the common counterargument is roughly "15 entities with intricate relationships, two decades of Core Data hardening versus three years of SwiftData, and the abstraction layer's stability doesn't automatically inherit the storage engine's." Both positions are held by people shipping real apps. A third camp (growing) picks GRDB and skips the object graph entirely.
[UNIVERSAL] Whatever you pick: design the migration story before v1 ships. Desktop apps hold years of irreplaceable user data. A schema you can't migrate is a product you can't update.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
macos, swiftui, appkit, darwin, xpc, apple-silicon, swift-concurrency
5 skills in this plugin
/desktop-cross-platform-and-architectureUse when choosing or using a cross-platform desktop framework (Electron vs Tauri, Flutter, Avalonia, Compose Multiplatform, Rust GUIs — the comparison table and the web-shell security checklist), structuring a desktop app (layering, state management, the document model with undo and autosave, threading and responsiveness, IPC and multi-process design, single instance and the launch protocol), or making an app feel native — windows, menus and keyboard, files, drag and drop and clipboard, dark mode and HiDPI, internationalization, accessibility, and the performance targets users perceive./desktop-linux-platformUse when building or debugging a Linux desktop app. Covers why 'Linux' is not one platform (the stack, XDG base directories, .desktop files and app IDs), D-Bus as the desktop's nervous system, PipeWire, the honest accessibility picture, GTK4 + libadwaita, Qt 6, the other toolkits, and the Wayland transition — what Wayland takes away from X11 (global hotkeys, window positioning, screen capture) and what replaces it (portals, layer-shell)./desktop-packaging-security-and-testingUse when shipping a desktop app: macOS code signing, the Hardened Runtime, notarization and stapling, the four macOS distribution channels including the Mac App Store; the Linux packaging matrix (Flatpak, Snap, AppImage, distro packages); auto-update (Sparkle, Squirrel, Flatpak); sandboxing and privacy (TCC, entitlements, the App Sandbox, Keychain and secrets, XDG portals, supply-chain and dependency risk); and the desktop testing pyramid, tools, and CI./desktop-referenceUse when reviewing a desktop app for anti-patterns, weighing contested questions (SwiftUI vs AppKit, native vs cross-platform, Electron vs Tauri, Flatpak vs Snap vs AppImage, GTK vs Qt, sandboxed vs unsandboxed, Wayland-first, Swift 6 strict concurrency, SwiftData vs Core Data vs GRDB, menu bar vs header bar), finding primary documentation and books, learning from the case studies and hard-won lessons, checking whether a platform claim is still current (snapshot verified August 2026), or needing the 'why doesn't my app feel native', 'won't launch on a user's Mac', and 'misbehaves on Linux' checklists. Companion to the other desktop-apps-macos-linux skills.npx claudepluginhub the-vibey-project/vibey --plugin desktop-apps-macos-linuxOther plugins' skills for the same job