macos-app-architecture

Guides architectural decisions for native macOS apps built with SwiftUI and AppKit.

2|Updated Sep 8, 2026
One-click install
npx skills add https://github.com/hanshi-notes/hanshi --skill macos-app-architecture-hanshi-notes
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: macos-app-architecture
Source: https://github.com/hanshi-notes/hanshi/tree/main/.agents/skills/macos-app-architecture
Command: npx skills add https://github.com/hanshi-notes/hanshi --skill macos-app-architecture-hanshi-notes

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Designing a native macOS app raises recurring structural questions—MV vs. MVVM, where state belongs, when to split into SwiftPM modules, how to handle Sparkle updates—that generic iOS-oriented guidance answers incorrectly or not at all. ## Core Features & Use Cases - Architecture decision layer: Twenty Quick Rules covering bounded-context stores, Environment-based dependency injection, Screen/View naming, enum-based events, and observation patterns, each backed by measured or verified evidence. - Anti-pattern catalog: Side-by-side wrong/right code for common mistakes such as one ViewModel per screen, sum-type view state, the AnyView shim across feature boundaries, and directory-watcher feedback loops. - Distribution and longevity guidance: Decisions that must be made before the first release, including sandbox impact on Sparkle entitlements, EdDSA key custody, and containing fragile third-party dependencies. - Use Case: When adding a settings screen with a Sparkle update check to a SwiftUI macOS app, consult the skill to learn why the updater must be owned by the App via @StateObject behind an UpdateChecking protocol rather than a global singleton. ## Quick Start Ask the AI to review your macOS app's structure against the macos-app-architecture skill's Quick Rules and anti-patterns before creating a new store, view, or module.

Frequently Asked Questions about macos-app-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Should I use MVVM or MV pattern in a SwiftUI macOS app?▼

The skill recommends the MV pattern: the SwiftUI view is already the presentation layer, so per-screen ViewModels duplicate it. Use one @Observable store per bounded context injected via the Environment, with presentation logic kept in views as computed properties.

When should I split a SwiftUI macOS app into SwiftPM modules?▼

Split only when a named pressure justifies it: a measurable build wait, encapsulation that internal cannot provide, or two owners colliding on the same files. Adding any declaration, even internal, recompiles every dependent module, so folders come first.

Does a sandboxed macOS app work with Sparkle auto-updates?▼

Yes, but a sandboxed app needs SUEnableInstallerLauncherService in Info.plist plus a mach-lookup temporary-exception entitlement listing the -spks and -spki service names. Shipping only half of this pair builds and notarizes but fails to install updates on user machines.

Why does my NSTextView fall back from TextKit 2 to TextKit 1?▼

Reading .layoutManager even once permanently drops an NSTextView from TextKit 2 to TextKit 1, silently. Assert textView.textLayoutManager != nil during setup and use textLayoutManager and textContentStorage APIs instead.

How do I observe an @Observable store from outside a SwiftUI view?▼

Publish domain events from the store as an AsyncStream rather than re-arming withObservationTracking, whose circulating wrapper does not compile in Swift 6 language mode. A main-actor-isolated AsyncStream property bridge remains valid for types you do not own.

What are the limitations of this architecture skill?▼

It deliberately excludes API reference material, delegating that to companion skills like swiftui-expert-skill and axiom-macos. It also assumes the file system as the model rather than SwiftData, and targets macOS rather than iOS navigation patterns.