appkit-interop
Bridge macOS SwiftUI into AppKit narrowly. Use when implementing representables, reaching NSWindow or panels, handling menus, or using the responder chain.
Savant verdict: Validated
Passed Savant's safety scan and scored 70+ on a live evaluation.
Live evaluation
75overall
79quality
83compliance
71grounding
77actionability
54efficiency
4 pass · 2 investigate · 2 fail across 8 cases. Jev accepted 8 of 16 LLM-drafted cases. Drafted and run by nvidia/nemotron-3-super-120b-a12b, validated and scored by jev-latest.
- I need to customize the title bar of a SwiftUI window to include a segmented control for view switching, similar to how Safari shows tab controls in its title bar. SwiftUI's toolbar doesn't give me the exact positioning I need.positive case · pass
- My app requires drag-and-drop of file URLs from Finder into a custom canvas view, but I need to validate that dropped files are image types before accepting them, and show a preview of the image during the drag. SwiftUI's dropDelegate doesn't let me inspect the pasteboard during dragging.positive case · pass
- I need to enable the 'Copy' menu item only when text is selected in an NSTextView wrapped in SwiftUI, but SwiftUI's @FocusedValue doesn't work with AppKit's first responder chain for menu validation.positive case · pass
- I need to handle a custom pasteboard type for dragging colored swatches between my app and a legacy design tool, but I'm unsure if SwiftUI's DragDrop APIs can handle the UTType conformity or if I need to drop to AppKit.edge case · investigate
- I want to implement a custom notification center UI that mimics the macOS Control Center with interactive widgets and quick settings toggles.negative case · fail
- How do I swizzle method implementations in AppKit classes to modify NSTextView's internal handling of ligatures for a SwiftUI-based text editor?negative case · pass
- I'm trying to make a SwiftUI view that behaves like a native macOS outline view with disclosure triangles, but I'm not sure if I should use NSOutlineView wrapped in NSViewRepresentable or build it with SwiftUI's Tree disclosure group.edge case · investigate
- I need to show a contextual menu when the user right-clicks on a SwiftUI canvas, but the menu should change based on what's under the cursor, like Xcode's interface builder. I'm using SwiftUI's contextMenu modifier but it doesn't feel native enough.edge case · fail
Safety (NVIDIA SkillSpector)
Risk score
0/100
Recommendation
SAFE
Severity
LOW
Savant decision
Passed
SkillSpector rated the package safe. SkillSpector 2.12.0, static analysis.
0 patterns found
Structure
- No license declaredConfirm you may reuse this skill before importing it into your repository.
SKILL.md
--- name: appkit-interop description: 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 `NSViewRepresentable` when you need a specific AppKit view with lightweight lifecycle needs. - Use `NSViewControllerRepresentable` when 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 1. Name the capability gap precisely. - Window behavior - Text system behavior - Menu validation - Drag and drop - File open/save panels - First responder control 2. Pick the smallest boundary that solves it. - Avoid porting a whole screen to AppKit when one wrapped control or coordinator would do. 3. Keep ownership explicit. - SwiftUI owns value state, selection, and observable models. - AppKit objects stay inside the representable, coordinator, or bridge object. 4. Expose a narrow interface back to SwiftUI. - Bindings for editable state - Small callbacks for events - Focused bridge services only when necessary 5. Validate lifecycle assumptions. - SwiftUI may recreate representables. - Coordinators exist to hold delegate and target-action glue, not as a second app architecture. ## References - `references/representables.md`: choosing between view and view-controller wrappers, plus coordinator patterns. - `references/window-panels.md`: window access, utility windows, and open/save panels. - `references/responder-menus.md`: first responder, command routing, and menu validation. - `references/drag-drop-pasteboard.md`: pasteboard, file URLs, and desktop drag/drop edges. ## Guardrails - Do not duplicate the source of truth between SwiftUI and AppKit. - Do not let `Coordinator` become an unstructured dumping ground. - Do not store long-lived `NSView` or `NSWindow` instances globally without a strong ownership reason. - Prefer a tiny tested bridge over rewriting the feature in raw AppKit. - If a pattern can remain entirely in `swiftui-patterns`, keep it there. ## Output Expectations Provide: - the exact SwiftUI limitation being crossed - the smallest recommended bridge type - the data-flow boundary between SwiftUI and AppKit - the lifecycle or validation risks to watch