I'm using Compose Multiplatform on iOS and embedding a ComposeUIViewController inside SwiftUI.
My hierarchy is:
SwiftUI ScrollView
└── UIViewControllerRepresentable
└── ComposeUIViewController
Example :
struct ComposeContainer: UIViewControllerRepresentable {
let factory: () -> UIViewController
func makeUIViewController(context: Context) -> UIViewController {
factory()
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
ScrollView {
ComposeContainer {
Main_iosKt.ChatViewController()
}
.fixedSize(horizontal: false, vertical: true)
}
The ComposeUIViewController is created like this:
fun buildComposeViewController(
content: @Composable () -> Unit
): UIViewController =
ComposeUIViewController {
content()
}
When inspecting the view, I always get:
intrinsicContentSize = (-1.0, -1.0)
which corresponds to UIView.noIntrinsicMetrics
As a result SwiftUI cannot determine the height and the view collapses.
I noticed the Compose Multiplatform 1.10.3 release notes mention “Autosizing Interop Views”, but documentation is still missing and YouTrack indicates documentation may arrive around 1.12
Can ComposeUIViewController expose its content height automatically?