Fatal Error: UIViewControllerRepresentables must be value types: ViewControllerResolver

Today, I made the first attempt at running an existing SwiftUI iOS app in Xcode 14.0 beta 2. In preview, simulator and device, attempting to display several of the views caused the a crash with this (simulator) warning:

SwiftUI/UIViewControllerRepresentable.swift:332: Fatal error: UIViewControllerRepresentables must be value types: ViewControllerResolver

2022-06-30 15:42:51.037629-0400 Shorty[8477:188610] SwiftUI/UIViewControllerRepresentable.swift:332: Fatal error: UIViewControllerRepresentables must be value types: ViewControllerResolver

The app runs in iOS 15 without this issue.

I have no idea where to start looking to fix this. How can I begin to troubleshoot this? I see no content from a search here or outside.

Does your app use UIViewControllerRepresentable? If so, is your data structure that uses UIViewControllerRepresentable a struct or a class?

The error message is saying you have a class that conforms to UIViewControllerRepresentable, and that you have to use a struct instead of a class.

Setting an exception breakpoint in Xcode and running the app can help you find where the app is crashing. Choose Debug > Breakpoints > Create Exception Breakpoint to set an exception breakpoint.

Thanks @szymczyk,

i had the exact same Problem (Fatal Error: UIViewControllerRepresentables must be value types:_). The problem was, that I was subclassing UIViewControllerRepresentable as a class instead of a struct. I'm not quit sure why this worked until updating to iOS16 but using struct does fix it.

Fatal Error: UIViewControllerRepresentables must be value types: ViewControllerResolver
 
 
Q