Key shortcut to open preview of SwiftUI code

You can use the OPT + CMD + ENTER as the key shortcut command to show the preview of your current SwiftUI code in Xcode:


To open the preview window for your current SwiftUI view, use this shortcut. The preview window lets you see how the user interface will look and function in a live environment, making it easier for you to design and test your code.

When you press OPT + CMD + ENTER, the preview window will appear showing the current SwiftUI view you are working on. You can see live changes made in the code as you make them. It’s very useful when working with SwiftUI because it allows you to test and debug your code without having to build and run the app on a simulator or device.

You can also use the Editor > Canvas menu to open the preview, which displays a preview of the last selected view.