swiftui-uikit-interop

Wrap UIKit views and view controllers for use in SwiftUI.

3|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/andrew-d/claude-skills --skill swiftui-uikit-interop-andrew-d
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-uikit-interop
Source: https://github.com/andrew-d/claude-skills/tree/main/plugins/swift-ios-skills--swiftui-skills/skills/swiftui-uikit-interop
Command: npx skills add https://github.com/andrew-d/claude-skills --skill swiftui-uikit-interop-andrew-d

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill bridges the gap between SwiftUI and UIKit, enabling developers to use components from either framework within the other, facilitating incremental adoption and leveraging existing UIKit libraries in SwiftUI apps.

Core Features & Use Cases

  • Wrap UIKit in SwiftUI: Use UIViewRepresentable and UIViewControllerRepresentable to embed UIKit views and view controllers (like UITextView, VNDocumentCameraViewController) within SwiftUI views.
  • Embed SwiftUI in UIKit: Use UIHostingController to present SwiftUI views from within UIKit view controllers.
  • State Synchronization: Manage data flow and state updates between the two frameworks using @Binding and coordinators.
  • Use Case: Integrate a complex UIKit-based camera preview or a third-party SDK into a new SwiftUI application, or incrementally migrate a large UIKit codebase to SwiftUI by replacing sections of the UI.

Quick Start

Use the swiftui-uikit-interop skill to wrap a UIKit UITextView for use in SwiftUI.

Frequently Asked Questions about swiftui-uikit-interop

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

FAQPage Schema
How do I use a UIKit view controller in SwiftUI?

You can embed a UIKit view in SwiftUI by adopting the `UIViewRepresentable` protocol. This wrapper creates a bridge to manage the UIKit component's lifecycle and synchronize its state with SwiftUI declarations.

Can I embed SwiftUI views inside a UIKit app?

Yes, you can embed SwiftUI views inside a UIKit app by using `UIHostingController`. This controller allows you to present SwiftUI views from within existing UIKit view controllers, facilitating incremental adoption of SwiftUI in legacy codebases.

What is the best way to migrate a large UIKit codebase to SwiftUI?

Migrating a large UIKit codebase to SwiftUI is best done incrementally. You can replace sections of the UI by wrapping new SwiftUI views in `UIHostingController` and embedding them within existing UIKit view controllers.

How do I synchronize state between UIKit and SwiftUI components?

You synchronize state between UIKit and SwiftUI using `@Binding` and the coordinator pattern. Coordinators act as delegates to handle UIKit events and propagate updates back to the SwiftUI视图, ensuring data flow remains consistent across both frameworks.

When should I use UIViewRepresentable instead of rewriting a component in SwiftUI?

You should use `UIViewRepresentable` when integrating a complex UIKit-based component like a camera preview or a third-party SDK that lacks a native SwiftUI equivalent, avoiding the need to rewrite existing functional UIKit libraries.