Live Preview Not Working for UIKit Unless I raise Deployment Target to iOS 17

In Xcode 15 Live Previews are available for UIKit view controllers and views. However I noticed they do not work if the deployment target is < 17.0.

If I try to make a live preview for a view controller like so:

#Preview {
    let someVC = ViewController()
    return someVC
}

It doesn't load.

The error is described below:

== PREVIEW UPDATE ERROR: CompileDylibError: Failed to build ASwiftViewController.swift Compiling failed: module 'SwiftUI' has no member named 'VStack'

If I raise the deployment target to iOS 17 it starts working.

I filed FB13215248

Same issue for me. I have a project that supports iOS 13 on UIKit. In Xcode 15 beta 2 all worked fine, I used preview for building custom UIViews with SnapKit. But in release version of Xcode 15 preview stop working. Until I rise up targets to iOS 17.

I have the same issue So I added @available(iOS 17.0, *) in front of the #Preview{} and It works

@available(iOS 17.0, *)
#Preview {
// Your Code
}
Live Preview Not Working for UIKit Unless I raise Deployment Target to iOS 17
 
 
Q