I'm converting XCP to #Preview macro and I was wondering if it's possible to make preview like this below.
#Preview {
struct DemoView: View {
// make view...
}
DemoView()
}
Is that possible? If so please let me know. If not, please explain..
#Previewmacro conforms to thePreviewRegistryprotocol, which has a static propertypreviewto locate previews at runtime. It returnsDeveloperToolSupport.Preview, and can contain a View or even a ViewController from UIKit in its body parameter.Your example code will not execute because you're missing
returnfor theDeveloperToolSupport.Previewbody. Basically, function builder will not work here. (which bypassreturnkeyword)