Is UIViewRepresentable even capable of handling autolayout within a view?

I have a UIView component that has a series of views within it: some UILabels, a UITextField, a couple UIImageViews, etc. All of it is held together with autolayout to work. It will stretch to whatever space I specify horizontally, but it very strictly handles the vertical space based on need. Here's what it should look like.



Now, I want to create a UIViewRepresentable so that I can use this component in a SwiftUI project. What I am finding is that I simply cannot find a way to have this component laid out correctly in SwiftUI. If I use


.fixedSize(horizontal: false, vertical: true)

the view disappears because no vertical space is allocated at all. If I use


.frame(width: 375.0, height: 100.0)


it will appear as expected but hardcoding the size is not possible for my needs. Same problem if I supply an


intrinsicContentSize


I can't know the height in advance.


Is there *any* way for SwiftUI to use a UIViewRepresentable to wrap this component and let autolayout dictate its size? How is this not possible?


I put together a barebones project that demonstrates the problem here as concisely as possible: https://www.dropbox.com/s/e5zqlmaqoosbv33/RepresentableSizing.zip?dl=0

Question is old but for the benefit of others I had this problem with SwiftUI having no size for the UIViewRepresentable. I solved it by adding an intrinsicContentSize variable in the base view (not the UIViewRepresentable wrapper), that calculates the size based on the key subview frames and some padding. eg.

Code Block swift
override var intrinsicContentSize: CGSize { textContainer.frame.size + (mainViewPadding * 2) }



But that defeats the whole point of autolayout. I've tested and indeed for a UIStackView with complex layout happening inside intrinsicContentSize is always returned as (-1;-1). I guess this is a issue with UIKit itself.

Is UIViewRepresentable even capable of handling autolayout within a view?
 
 
Q