swiftui-macos-patterns

Community

Master macOS SwiftUI state and architecture patterns

AuthorLaughingJackalope
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill solves the frequent bugs, crashes, and poor user experience caused by inconsistent state management, broken menu command validation, and incorrect environment injection in macOS SwiftUI applications, which are common pain points for developers building native macOS software with SwiftUI.

Core Features & Use Cases

  • Modern State Management Patterns: Covers @Observable, @State, @Binding, @Environment, @AppStorage, and @SceneStorage for all macOS SwiftUI state ownership and persistence scenarios.
  • Menu Command Validation: Implements the focused values system (@FocusedValue, @FocusedBinding, @FocusedObject) to automatically enable/disable menu items based on the state of the currently focused view, replacing legacy NSMenuItemValidation patterns.
  • macOS-Specific Architecture Wiring: Provides production-ready patterns for scene-scoped environment injection, Settings scene state sharing, focus system implementation, and App Groups-backed UserDefaults integration for multi-window and document-based apps.
  • Use Case Example: A document-based macOS app can use these patterns to implement per-window document state, validate Save/Export menu items based on the active editor, and share user preferences between the main window and Settings scene without runtime crashes.

Quick Start

Use the swiftui-macos-patterns skill to implement @Observable view models with @FocusedValue menu validation for your macOS document editor app, so Save and Export menu items automatically enable when a document is active and disable when no editor is focused.

Dependency Matrix

Required Modules

None required

Components

references

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: swiftui-macos-patterns
Download link: https://github.com/LaughingJackalope/macos-skills/archive/main.zip#swiftui-macos-patterns

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 536,000+ vetted skills library on demand.