Preview fails in part1 - can't follow along

This problem was posted previously but the answer was to update MacOS and Xcode. I am using the latest versions and the problem persists - for me at least.

This is probably something really simple that everyone does and I just don't know about.

I installed MacOS Monterey, XCode and downloaded the Building a Great Mac App with SwiftUI sample code so I can code along. After opening the workspace I added a developer account and added an Apple Development certificate. I think I should be able to build code now.

I configure my developer team (for the target) to the development account I just setup, and the signing certificate to "Development".

2 warnings appear before I do anything: asking me to enable hardened runtime. Since it recommends I should do this, I tell it it's ok to go ahead and configure this. This gets rid of all the warnings for the moment.

I open the ContentView (Part1 start -> GardenApp -> Garden App -> Navigation -> ContentView). An error shows instead of a preview: "Cannot preview the file - active scheme does not build this file". There's an information icon next to the error that reveals: "Select a scheme that builds a target which contains the current file, or add this file to a target that is built by the current scheme."

When I search for "scheme" in the build settings I get nothing.

This seems pretty odd. Any suggestions on how to resolve this would be great.

Accepted Reply

This must be bugs in the software. I opened the Product -> Scheme -> Manage Schemes... menu item and explored the configuration. I didn't change anything and when I closed the configuration window the preview was magically working.

Now when I close and open Xcode the preview works.

Replies

This must be bugs in the software. I opened the Product -> Scheme -> Manage Schemes... menu item and explored the configuration. I didn't change anything and when I closed the configuration window the preview was magically working.

Now when I close and open Xcode the preview works.