swiftui-uikit-interop

Bridge UIKit views and controllers with SwiftUI using representable wrappers.

Updated May 10, 2026
One-click install
npx skills add https://github.com/FelixRauch/medat-figuren --skill swiftui-uikit-interop-felixrauch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-uikit-interop
Source: https://github.com/FelixRauch/medat-figuren/tree/main/.agents/skills/swiftui-uikit-interop
Command: npx skills add https://github.com/FelixRauch/medat-figuren --skill swiftui-uikit-interop-felixrauch

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It solves the integration problem of reusing UIKit views and view controllers inside a SwiftUI app (and vice versa) without breaking state updates, layout, or delegate callbacks.

Core Features & Use Cases

  • Wrap UIKit views in SwiftUI: Use UIViewRepresentable to embed UIKit UIView subclasses while keeping SwiftUI state and UIKit behavior synchronized.
  • Wrap UIKit controllers in SwiftUI: Use UIViewControllerRepresentable to present and coordinate UIKit-only flows (pickers, scanners, mail, shares, PDF/document viewers).
  • Coordinate delegate callbacks safely: Use the Coordinator pattern to bridge delegate/data-source events back into SwiftUI via @Binding and closures, while avoiding update loops and retain cycles.
  • Host SwiftUI inside UIKit: Use UIHostingController (and UIHostingConfiguration for iOS 16+) to embed SwiftUI content into UIKit containers and cells with correct sizing.
  • Manage state, layout, and environment across the boundary: Apply sizing options, prevent redundant updates, and bridge environment/trait behavior reliably.

Quick Start

Use the swiftui-uikit-interop skill to wrap a UITextView for attributed text editing with UIViewRepresentable, coordinating delegate-driven edits back to a SwiftUI @Binding for smooth two-way sync.

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 UIView in SwiftUI and keep state synchronized?

To wrap a UIKit UIView in SwiftUI, use UIViewRepresentable and implement the Coordinator pattern to bridge delegate callbacks back to SwiftUI state via @Binding, ensuring two-way synchronization without update loops.

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

Embedding SwiftUI views inside UIKit requires UIHostingController or UIHostingConfiguration for iOS 16+, managing proper hosting containment, sizing, and trait environment propagation to ensure reliable layout and state behavior.

How do I use UIKit view controllers like document scanners or mail composers in SwiftUI?

Use UIViewControllerRepresentable to present and coordinate UIKit-only flows like document scanners, mail composers, and share sheets in SwiftUI, leveraging the Coordinator pattern to handle delegate callbacks safely.

Why do my SwiftUI and UIKit interop updates cause layout loops or retain cycles?

Layout loops and retain cycles in SwiftUI and UIKit interop happen when state updates are unguarded; fix them by correctly separating make and update lifecycles and using guarded state updates to prevent redundant rendering.

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

Incremental UIKit to SwiftUI migration is possible by embedding SwiftUI content into existing UIKit containers with UIHostingController while wrapping remaining UIKit views and controllers in SwiftUI using UIViewRepresentable.

Does UIHostingController support correct sizing and environment propagation for SwiftUI content?

UIHostingController supports correct sizing and environment propagation by applying specific sizing options and bridging environment and trait behavior, preventing redundant updates when embedding SwiftUI content into UIKit containers.