Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the cannot find type 'UIHostingController' in scope error while building iOS app

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).

like image 988
yuraist Avatar asked Jan 24 '23 10:01

yuraist


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.

like image 60
darkfire613 Avatar answered May 20 '23 02:05

darkfire613