I'm unable to render a Compose Multiplatform view inside a SwiftUI Form. However, it works outside of the Form.
SwiftUI view:
struct ContentView: View {
var body: some View {
Form {
Section {
KMPView()
}
}
KMPView()
}
}
struct KMPView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> UIViewController {
return KMPView_iosKt.ComposeEntryPoint()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
}
}
KMPView.ios.kt:
import androidx.compose.ui.window.ComposeUIViewController
import androidx.compose.material.Text
import platform.UIKit.UIViewController
fun ComposeEntryPoint(): UIViewController =
ComposeUIViewController {
Text("Hello from Compose")
}
This results in the view inside the Form not being rendered but the one outside of it works fine