Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot preview in this file - active scheme does not build this file : SwiftUI on Xcode 11 in CatalinaOS

I opened Landmark App using SwiftUI on Xcode 11 in macOS Catalina(10.15) and while opening the Canvas Editor for .swift files containing SwiftUI is showing

Cannot preview in this file - active scheme does not build this file

Try Again, Diagonistics option or restarting Xcode not solving the problem.

like image 602
rarahat02 Avatar asked Oct 16 '19 15:10

rarahat02


People also ask

How do I create a preview in SwiftUI?

You can also create new preview structures in an existing SwiftUI view file by choosing Editor > Create Preview. For the complete list of preview customizations, see Previews in Xcode.

How do I open preview in SwiftUI?

There are two shortcuts that you should remember. Both of them will make your life easier during the development cycle of your SwiftUI views. Cmd + Option + Enter shows or hides previews. Cmd + Option + P runs the previews.

Is SwiftUI included in Xcode?

SwiftUI is more than a framework. It is integrated into Xcode, enabling developers to build user interfaces much faster than ever before.

How do I create a SwiftUI file?

Choose File > New > File, select iOS as the platform, select the “SwiftUI View” template, and click Next. Name the new file MapView. swift and click Create.


2 Answers

If this is a new project coming from a copied folder and inside an iCloud folder, just close Xcode and relaunch it. The sync was not yet done.

like image 88
Alain ANDRE Avatar answered Sep 25 '22 19:09

Alain ANDRE


Select the Scheme that has the current file to Preview
enter image description here

like image 43
ILYA2606 Avatar answered Sep 23 '22 19:09

ILYA2606