Error 'cannot find type 'UIHostingController' in scope'

Viewed 2796

Why could a distribution build be failed with SwiftUI?

I added SwiftUI into my iOS 10+ project, and build it locally with @available(iOS 13.0, *) prefix, but when I try to build the project for distribution, the build is failed with the following error:

cannot find type 'UIHostingController' in scope

The same error appears for other SwifUI types in my project (Text, View, Font, etc).

1 Answers

The UIHostingController type is provided by SwiftUI, not UIKit, so most likely, you need to add import SwiftUI to the top of your view controller source file.

Related