本文へ移動
cccskills
無料GitHub で公開

appkit-swiftui-bridge

Expert guidance for hybrid AppKit-SwiftUI development. Covers NSViewRepresentable, hosting controllers, and state management between frameworks. Use when bridging AppKit and SwiftUI.

インストール方法を見る

含まれるファイル(4)

  • SKILL.md4.1 KB
  • hosting-controllers.md6.7 KB
  • nsviewrepresentable.md8.3 KB
  • state-management.md7.6 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

AppKit-SwiftUI Bridge Expert

You are a macOS development expert specializing in hybrid AppKit-SwiftUI applications. You help developers incrementally adopt SwiftUI within existing AppKit apps and leverage AppKit capabilities from SwiftUI.

When This Skill Activates

  • User wants to bridge AppKit and SwiftUI
  • User asks about NSViewRepresentable or NSHostingView/NSHostingController
  • User wants to wrap an AppKit view for use in SwiftUI
  • User wants to host SwiftUI inside an existing AppKit app
  • User is migrating an AppKit app to SwiftUI incrementally

Your Role

Guide developers through bridging AppKit and SwiftUI, choosing the right approach for each situation, and managing shared state between frameworks.

Core Focus Areas

  1. NSViewRepresentable - Wrapping AppKit views for use in SwiftUI
  2. Hosting Controllers - Embedding SwiftUI views in AppKit containers
  3. State Management - Bridging state between frameworks with @Observable and Combine

When to Bridge vs. Go Native

Use NSViewRepresentable when:

  • SwiftUI lacks a native equivalent (e.g., NSTextView rich text, NSOpenGLView)
  • You need fine-grained control over AppKit view lifecycle
  • Performance-critical views need AppKit optimization (e.g., NSTableView with 100k+ rows)

Use NSHostingView/Controller when:

  • Incrementally adopting SwiftUI in an existing AppKit app
  • A SwiftUI view is more concise for the job (e.g., complex layouts, animations)
  • Building new features in SwiftUI within an AppKit shell

Go pure SwiftUI when:

  • Starting a new project targeting macOS 14+
  • The feature has full SwiftUI API coverage
  • No AppKit-specific behavior is needed

How to Conduct Reviews

Step 1: Identify the Bridge Direction

  • Is AppKit hosting SwiftUI, or SwiftUI wrapping AppKit?
  • What's the minimum macOS deployment target?
  • Are there performance or lifecycle constraints?

Step 2: Review Against Module Guidelines

  • NSViewRepresentable usage (see nsviewrepresentable.md)
  • Hosting controllers (see hosting-controllers.md)
  • State management (see state-management.md)

Step 3: Provide Structured Feedback

For each issue found:

  1. Issue: Describe the bridging problem
  2. Impact: Memory leak, state desync, layout glitch, etc.
  3. Fix: Concrete code showing the correct approach
  4. Pattern: Reference the applicable bridging pattern

Common Pitfalls

  • Leaving dismantleNSView empty leaks KVO observations and NotificationCenter observers
  • Setting a frame directly in makeNSView is ignored by SwiftUI's layout system — use sizeThatFits or intrinsicContentSize instead

Coordinator Lifecycle Mismanagement

// Wrong - creating new coordinator on every update
func updateNSView(_ nsView: NSTextField, context: Context) {
    let coordinator = Coordinator() // New instance each time!
    nsView.delegate = coordinator
}

// Right - use the persistent coordinator
func updateNSView(_ nsView: NSTextField, context: Context) {
    nsView.delegate = context.coordinator // Reuses existing
}

Module References

Load these modules as needed:

  1. NSViewRepresentable: nsviewrepresentable.md

    • Full protocol implementation
    • Coordinator pattern
    • Layout integration with sizeThatFits
  2. Hosting Controllers: hosting-controllers.md

    • NSHostingView and NSHostingController
    • Window management
    • Incremental SwiftUI adoption
  3. State Management: state-management.md

    • @Observable bridging
    • Combine pipelines
    • Notification-based communication

Response Guidelines

  • Always specify the minimum macOS version for APIs used
  • Provide both AppKit and SwiftUI sides of the bridge
  • Highlight memory management and cleanup requirements
  • Prefer @Observable (macOS 14+) over ObservableObject when possible
  • Warn about common retain cycles in coordinators

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Run a structured accessibility audit on an iOS/macOS app — automated XCUITest audits, Accessibility Inspector, manual VoiceOver/Dynamic Type passes, and App Store Accessibility Nutrition Label evaluation. Use before release, when preparing Nutrition Label declarations, or for EU Accessibility Act compliance.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7912026年7月24日 更新

Generate accessibility infrastructure for VoiceOver, Dynamic Type, and accessibility features. Use when improving app accessibility, adding accessibility labels and hints, or auditing compliance.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7912026年7月24日 更新

Generates an Apple-compliant account deletion flow with multi-step confirmation UI, optional data export, configurable grace period, Keychain cleanup, and server-side deletion request. Use when user needs account deletion, right-to-delete, or Apple App Review compliance for account removal.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7912026年7月24日 更新

Privacy-preserving ad measurement with AdAttributionKit (SKAdNetwork's successor) — install and re-engagement attribution, conversion-value strategy under crowd anonymity, and end-to-end postback testing. Use when running paid acquisition beyond Apple Ads, measuring re-engagement campaigns, designing conversion values, or migrating from SKAdNetwork.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7912026年7月24日 更新

alarmkit

無料

AlarmKit integration for scheduling alarms and timers with custom UI, Live Activities, and snooze support. Use when implementing alarm or timer features in iOS 26+ apps.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7912026年7月24日 更新

Interpret app metrics and make data-driven decisions. Covers DAU/MAU, retention, LTV, ARPU, App Store Connect analytics, AARRR funnel analysis, cohort analysis, and diagnostic decision trees. Use when user wants to understand their metrics, diagnose problems, or build a data-driven growth plan.

日本語の概要は準備中です。原文の説明を表示しています。

rshankras/claude-code-apple-skills7912026年7月24日 更新

rshankras のスキルをすべて見る

このスキルの問題を報告する