How to integrate native SwiftUI views into Compose Multiplatform using UIKitView?

14 hours ago 2
ARTICLE AD BOX

I am building a Compose Multiplatform (CMP) application and need to leverage some iOS-specific native components (like MapKit or a custom SwiftUI chart) that are already built in SwiftUI.

While CMP provides excellent UI sharing, I need to ensure these specific components maintain their native performance and look-and-feel. I understand that I need to use UIKitView to bridge native iOS views, but I'm struggling with the boilerplate required to wrap a SwiftUI View into something Compose can render in iosMain.

The Goal:

I want to pass a title string from my shared Compose code and have it rendered inside a native SwiftUI VStack.

My Current Setup:

In my commonMain, I have an expect function:

Kotlin

@Composable expect fun NativeButton(title: String, onAction: () -> Void)

The Challenge:

How do I implement the actual side in iosMain? Specifically:

How do I use UIHostingController to convert the SwiftUI view into a UIViewController?

How do I extract the UIView from that controller for use inside the UIKitView factory?

How do I handle updates if the title state changes in Compose?

Any guidance on the standard 2026 patterns for this interop would be greatly appreciated!

Read Entire Article