swiftui-uikit-interop

Wrap UIKit views and controllers in SwiftUI using representable wrappers and Coordinators.

Updated May 6, 2026
One-click install
npx skills add https://github.com/Roy-wonji/claude-config --skill swiftui-uikit-interop-roy-wonji
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-uikit-interop
Source: https://github.com/Roy-wonji/claude-config/tree/main/skills/swiftui-uikit-interop
Command: npx skills add https://github.com/Roy-wonji/claude-config --skill swiftui-uikit-interop-roy-wonji

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Integrating UIKit-only views, view controllers, and delegate-driven SDKs into a SwiftUI app without losing state sync, layout correctness, or lifecycle safety.

Core Features & Use Cases

  • Wrap UIKit views for SwiftUI with UIViewRepresentable, including correct lifecycle handling via makeUIView and updateUIView, plus optional sizing with sizeThatFits.
  • Wrap UIKit controllers for SwiftUI with UIViewControllerRepresentable, capturing delegate callbacks using a Coordinator and routing results back through @Binding.
  • Embed SwiftUI within UIKit using UIHostingController (and optionally UIHostingConfiguration for iOS 16+ cell use), with correct containment and sizing.
  • State and environment synchronization across the boundary using @Binding, coordinator-driven updates, and SwiftUI context.environment (plus migration-focused references).

Quick Start

Use the swiftui-uikit-interop skill to design a UIViewRepresentable or UIViewControllerRepresentable wrapper for your UIKit component, wiring delegate callbacks back into SwiftUI with bindings and a Coordinator.

Frequently Asked Questions about swiftui-uikit-interop

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

FAQPage Schema
How do I wrap a UIKit view in SwiftUI using UIViewRepresentable?

To wrap a UIKit view in SwiftUI, use UIViewRepresentable and implement makeUIView to instantiate the view and updateUIView to apply state changes. This ensures correct lifecycle handling and state synchronization across the boundary.

How do I capture UIKit delegate callbacks and route them to SwiftUI?

Capture UIKit delegate callbacks by implementing a Coordinator class inside UIViewControllerRepresentable. The Coordinator acts as the delegate, receives the callbacks, and routes the results back into SwiftUI through @Binding properties.

What's the best way to embed SwiftUI views inside a UIKit app?

Embed SwiftUI views inside a UIKit app using UIHostingController. For iOS 16+ table or collection view cells, use UIHostingConfiguration to achieve correct containment, sizing, and seamless integration.

Why does my SwiftUI wrapper lose state sync with my UIKit component?

State sync is lost when lifecycle logic is misplaced. Ensure UIKit views are created in makeUIView and updated in updateUIView. Use the Coordinator pattern with @Binding to properly synchronize state and prevent update failures.

Can I incrementally migrate a UIKit app to SwiftUI without rewriting everything?

Yes, you can incrementally migrate a UIKit app to SwiftUI by wrapping existing UIKit views and controllers with UIViewRepresentable and UIViewControllerRepresentable, allowing both frameworks to coexist while maintaining state sync.

Do I need to handle retain cycles when bridging UIKit and SwiftUI?

Yes, you need to handle retain cycles when bridging UIKit and SwiftUI. Properly manage retain-cycle safety and sizing within your UIViewRepresentable wrappers to ensure stable memory management and correct layout.