appkit-interop

Bridge SwiftUI into AppKit for representables, windows, menus, and responder-chain behavior on macOS.

Updated Jul 31, 2026
One-click install
npx skills add https://github.com/AarnavBaddam/skills --skill appkit-interop-aarnavbaddam
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: appkit-interop
Source: https://github.com/AarnavBaddam/skills/tree/main/appkit-interop
Command: npx skills add https://github.com/AarnavBaddam/skills --skill appkit-interop-aarnavbaddam

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? SwiftUI covers most macOS UI needs, but some native behaviors—NSWindow access, menu validation, open/save panels, first-responder control, and AppKit-specific drag and drop—require dropping into AppKit. This Skill guides you to the smallest possible bridge so SwiftUI remains the source of truth while AppKit handles the imperative edge. ## Core Features & Use Cases - Bridge Selection Guidance: Decide between pure SwiftUI, NSViewRepresentable, NSViewControllerRepresentable, or direct AppKit hooks based on the exact capability gap. - Reference Patterns: Covers representable wrappers with coordinators, window and panel access, responder-chain and menu validation, and pasteboard/drag-drop edges. - Use Case: You need an NSTextView with delegate callbacks inside a SwiftUI screen. The Skill provides a complete NSViewRepresentable skeleton with a Coordinator that syncs text via bindings without infinite update loops. ## Quick Start Ask the assistant to wrap an NSTextView in a SwiftUI view using the smallest AppKit bridge with a coordinator for delegate callbacks.

Frequently Asked Questions about appkit-interop

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

FAQPage Schema
How do I wrap an AppKit view in SwiftUI on macOS?

Use NSViewRepresentable for view-level bridges like NSTextView or NSScrollView, and NSViewControllerRepresentable when you need controller lifecycle or delegation. Keep delegate wiring in a Coordinator and only push state into AppKit when values actually change.

NSViewRepresentable vs NSViewControllerRepresentable: which should I use?

Choose NSViewRepresentable for a single AppKit view with lightweight lifecycle needs. Choose NSViewControllerRepresentable when you need controller lifecycle, delegate coordination, or AppKit presentation logic such as presenting sheets or managing child controllers.

How do I access NSWindow from a SwiftUI macOS app?

Prefer SwiftUI Window, WindowGroup, and openWindow first. Use AppKit only for window features SwiftUI does not expose, such as titlebar configuration or utility panels, and avoid letting random views own long-lived NSWindow references.

Can I use NSOpenPanel and NSSavePanel with SwiftUI?

Yes, present NSOpenPanel or NSSavePanel through a small helper or service rather than scattering panel setup across the view tree. A simple runModal call returning the selected URL keeps the boundary clean.

Why does my SwiftUI representable cause infinite update loops?

Update loops happen when updateNSView pushes state into AppKit unconditionally, triggering delegate callbacks that write back the same value. Guard updates by comparing the current AppKit value with the SwiftUI state before assigning.

When should I avoid bridging to AppKit entirely?

Avoid AppKit when SwiftUI scenes, toolbars, commands, inspectors, or standard controls already provide the behavior. If a pattern fits entirely within SwiftUI focused values and commands, keep it there instead of recreating AppKit-style global handling.