
SwiftUI and AppKit Bridge
Bridges SwiftUI to AppKit narrowly for representables, windows, menus and responders.
Install
npx skills add robinebers/openusage --skill macos-appkit-interop -g -a claude-code -y- Repository
- robinebers/openusage4.5k
- Category
- Engineering
- Updated
- 3d ago
- License
- MIT
- Context cost
- Lightabout 658 tokens
- Runs scripts
- No, instructions only
What it does
Bridge macOS SwiftUI into AppKit narrowly. Use when implementing representables, reaching NSWindow or panels, handling menus, or using the responder chain.
AppKit Interop
Quick Start
Use this skill when SwiftUI is close but not quite enough for native macOS behavior. Keep the bridge as small and explicit as possible. SwiftUI should usually remain the source of truth, while AppKit handles the imperative edge.
Choose The Smallest Bridge
- Use pure SwiftUI when the required behavior already exists in scenes, toolbars, commands, inspectors, or standard controls.
- Use
NSViewRepresentablewhen you need a specific AppKit view with lightweight lifecycle needs. - Use
NSViewControllerRepresentablewhen you need controller lifecycle, delegation, or presentation coordination. - Use direct AppKit window or app hooks when you need
NSWindow, responder-chain, menu validation, panels, or app-level behavior.
Workflow
-
Name the capability gap precisely.
- Window behavior
- Text system behavior
- Menu validation
- Drag and drop
- File open/save panels
- First responder control
-
Pick the smallest boundary that solves it.
- Avoid porting a whole screen to AppKit when one wrapped control or coordinator would do.
-
Keep ownership explicit.
- SwiftUI owns value state, selection, and observable models.
- AppKit objects stay inside the representable, coordinator, or bridge object.
-
Expose a narrow interface back to SwiftUI.
- Bindings for editable state
- Small callbacks for events
- Focused bridge services only when necessary
-
Validate lifecycle assumptions.
- SwiftUI may recreate representables.
- Coordinators exist to hold delegate and target-action glue, not as a second app architecture.
