macos-appkit-swiftui-bridge

Bridge AppKit and SwiftUI view lifecycles and state for hybrid macOS UI integration.

4|1|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill macos-appkit-swiftui-bridge
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: macos-appkit-swiftui-bridge
Source: https://github.com/AutisticAF/claude-code-apple-dev-plugin/tree/main/skills/macos-appkit-swiftui-bridge
Command: npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill macos-appkit-swiftui-bridge

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides expert guidance to integrate SwiftUI into existing AppKit macOS applications and to wrap AppKit views for use in SwiftUI, resolving lifecycle mismatches, layout sizing issues, and state synchronization problems that commonly cause memory leaks, stale UI, or poor performance.

Core Features & Use Cases

  • NSViewRepresentable guidance: Full protocol patterns, coordinator lifecycle, sizing integration, and dismantle cleanup for embedding AppKit views in SwiftUI.
  • Hosting controllers & views: Best practices for NSHostingView and NSHostingController usage, window and toolbar integration, and incremental migration strategies.
  • State management across frameworks: Recommended approaches using @Observable, Combine, NotificationCenter, and responder chain patterns with attention to thread safety and retain-cycle avoidance.
  • Use Case: Incrementally adopt SwiftUI by replacing a complex AppKit detail view with an NSHostingView while sharing a single observable view model between AppKit controllers and SwiftUI views.

Quick Start

Use the macos-appkit-swiftui-bridge skill to review an AppKit view and produce a migration plan with an NSViewRepresentable wrapper, coordinator lifecycle handling, and dismantle cleanup.

Frequently Asked Questions about macos-appkit-swiftui-bridge

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

FAQPage Schema
How do I integrate SwiftUI views into an existing AppKit macOS application?

Use NSHostingController or NSHostingView to embed SwiftUI within AppKit. This bridge provides best practices for window and toolbar integration, plus incremental migration strategies to replace AppKit views without rewriting your entire app.

How do I wrap AppKit views for use in SwiftUI?

Wrap AppKit views using the NSViewRepresentable protocol. You need to implement coordinator lifecycle handling, sizing integration, and dismantle cleanup to prevent memory leaks and ensure correct layout behavior within SwiftUI.

What is the best way to synchronize state between AppKit and SwiftUI?

Synchronize shared state using @Observable, Combine, or NotificationCenter. You must manage thread safety and avoid retain cycles when sharing a single observable view model between AppKit controllers and SwiftUI views.

Why does my NSViewRepresentable wrapper cause memory leaks in macOS?

Memory leaks occur due to incorrect coordinator lifecycle handling and missing dismantle cleanup. Properly implement the coordinator pattern and dismantle methods in your NSViewRepresentable to ensure memory-safe state synchronization.

Can I use @Observable with AppKit and SwiftUI on macOS?

Yes, @Observable works for shared state management across AppKit and SwiftUI. Apply it to avoid retain cycles and ensure thread-safe synchronization when passing a view model between legacy controllers and modern views.