swiftui-uikit-interop

Bridge UIKit and SwiftUI with representable wrappers and coordinator delegates.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/DFly7/iOS-FastAPI-Supabase-AI --skill swiftui-uikit-interop-dfly7
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-uikit-interop
Source: https://github.com/DFly7/iOS-FastAPI-Supabase-AI/tree/main/.agents/skills/swiftui-uikit-interop
Command: npx skills add https://github.com/DFly7/iOS-FastAPI-Supabase-AI --skill swiftui-uikit-interop-dfly7

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Integrating legacy or platform-only UIKit components into modern SwiftUI apps is error-prone and full of lifecycle, sizing, and delegate synchronization pitfalls; this Skill documents patterns to reliably wrap views and view controllers, embed SwiftUI inside UIKit, and keep state consistent across the boundary.

Core Features & Use Cases

  • UIViewRepresentable & UIViewControllerRepresentable: Clear lifecycle rules for creating, updating, sizing, and dismantling UIKit hosts in SwiftUI.
  • Coordinator Pattern & Delegation: Best practices for wiring delegates, avoiding retain cycles, and routing results back to SwiftUI via bindings or closures.
  • UIHostingController Embedding & Sizing: Correct child containment, sizingOptions usage, and strategies for Auto Layout, intrinsic sizing, and collection/table view hosting.
  • State Synchronization & Concurrency: Two-way @Binding sync patterns, environment bridging, and MainActor/Sendable considerations for modern Swift concurrency.
  • Use Cases: Camera previews, map views, document scanners, mail/message composers, PDF rendering, legacy screen migrations, and collection/table view SwiftUI cell hosting.

Quick Start

Wrap your UIKit view or controller using UIViewRepresentable or UIViewControllerRepresentable, set up a Coordinator to forward delegate callbacks into @Binding properties, and embed or present the resulting wrapper where you need it.

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, implement UIViewRepresentable to manage creation, updating, sizing, and dismantling lifecycle rules, ensuring reliable integration of platform-only components.

How does the coordinator pattern work with UIViewControllerRepresentable in SwiftUI?

The coordinator pattern with UIViewControllerRepresentable wires UIKit delegates to SwiftUI, avoiding retain cycles and routing callback results back through @Binding properties or closures.

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

Embedding SwiftUI inside UIKit uses UIHostingController with proper child containment, sizingOptions, Auto Layout, and intrinsic sizing strategies to maintain consistent state across the boundary.

Can I synchronize state and delegate interactions between UIKit and SwiftUI?

Yes, you can synchronize state and delegate interactions using two-way @Binding sync patterns, environment bridging, and MainActor or Sendable considerations for modern Swift concurrency.

Does UIHostingController support sizing for collection and table view cells?

UIHostingController supports sizing for collection and table view cells through proper child containment, sizingOptions usage, and intrinsic sizing strategies for reliable Auto Layout rendering.

Why does my UIKit to SwiftUI migration break delegate callbacks?

UIKit to SwiftUI migrations break delegate callbacks due to lifecycle and sizing pitfalls; using representable lifecycles and coordinator delegate patterns correctly routes results back to SwiftUI.