Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Bridges UIKit and SwiftUI with representables, UIHostingController, coordinators, and observation tracking for shared state.
73% 100%+27 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 16 of 22 without it.
I'm building an iOS app where I need to wrap a native UISearchBar inside SwiftUI so I can filter items live with two-way binding. Can you show me how to write a complete UIViewRepresentable wrapper with a coordinator for delegate callbacks, including proper state sync handling?
Annotates the Coordinator class with @MainActor.
3 of 3 safety checks passed
Bridge UIKit and SwiftUI in both directions: wrap UIKit views and controllers, embed SwiftUI in UIKit screens, and synchronize state without duplicating lifecycle ownership.
See references/representable-recipes.md for complete wrapping recipes and references/hosting-migration.md for UIKit-to-SwiftUI migration patterns.
Use UIViewRepresentable to wrap any UIView subclass for use in SwiftUI.
struct WrappedTextView: UIViewRepresentable {
@Binding var text: String
func makeUIView(context: Context) -> UITextView {
// Called ONCE when SwiftUI inserts this view into the hierarchy.
// Create and return the UIKit view. One-time setup goes here.
let textView = UITextView()
textView.delegate = context.coordinator
textView.font = .preferredFont(forTextStyle: .body)
return textView
}
func updateUIView(_ uiView: UITextView, context: Context) {
Next to this one in the catalogue, plus more from the same author.