What problem does it solve?
Integrating UIKit components and third-party UIKit SDKs into a SwiftUI app (and embedding SwiftUI into UIKit) is error-prone due to lifecycle differences, delegate patterns, sizing mismatches, and concurrency boundaries. This Skill provides patterns, recipes, and checklist items to reliably wrap UIView and UIViewController classes, host SwiftUI inside UIKit, and keep state synchronized across the boundary so UI, accessibility, and presentation semantics remain correct.
Core Features & Use Cases
- Wrap UIKit views with UIViewRepresentable and view controllers with UIViewControllerRepresentable for use in SwiftUI.
- Implement the Coordinator pattern to route delegate callbacks and avoid retain cycles; use dismantle hooks to clean up observers and timers.
- Embed SwiftUI in UIKit using UIHostingController and UIHostingConfiguration (iOS 16+) with proper containment, Auto Layout, and sizing strategies.
- State synchronization patterns: @Binding two-way sync, closures for one-way events, environment bridging, and approaches for @Observable/Combine interop.
- Concurrency and safety guidance for main-actor isolation and Sendable considerations when coordinators implement UIKit delegates.
- Use cases: camera previews, map views, document scanners, mail/message composers, PDF viewers, rich text editors, collection/table cells with SwiftUI content, and incremental migration of large UIKit apps.
Quick Start
Wrap the UIKit view or view controller with UIViewRepresentable or UIViewControllerRepresentable, create a Coordinator to handle delegate callbacks, implement make/update/dismantle methods, and embed with UIHostingController when hosting SwiftUI inside UIKit.