Cannot Preview in this file errors

Hello,

I keep getting “Cannot preview in this file - active scheme does not build this file” errors frequently when starting a starter project for each chapter. Sometimes doing a clean then build fixes it, sometimes closing the project then reopening it fixes it.

I see this frequently, what am I missing?

Thanks,

GreyBeard

hi Warren! which destination target are you using?

in Xcode 13.1, I’m getting a different but similar preview error, only for some older simulator devices, like SE and 8:

Screen Shot 2021-11-04 at 11.32.17

I had expected to see your error for the newer devices, since the book’s code targets iOS 14, not 15. But new devices aren’t a problem.

Hi Audrey,

I’m building for iPad Pro on iOS 14.0.
I’m using xcode 13.1 running under Monterey 12.0.1.
Preview is now working after closing xcode then re-opening it.

I thought Android Studio was flaky but this is a whole new level of flakiness.
I did iOS dev years ago and xcode was very stable and reliable then.

Thank you for responding,

Warren

Jobs ran a very tight ship.

OTOH Xcode now needs to support a lot more features.

I am working with your 2nd edition, latest version of box iosMac and Xcode. I am new with Apple platform. How come I have the same error? I have no idea what to do? I really want to work through you book but I am stuck in chapter 2. Any suggestions? The build is for iPhone 14 pro.

Maybe I could just copy and paste the code and setup a new project with the same name. It might/should work. Otherwise, to the used book trading house!?

hi Luis! try running the project in the final folder? If that also fails, quit and restart Xcode. If that fails, restart the Mac. I suppose you don’t have any earlier version of Xcode on your Mac? you got it new, not 2nd hand?

Also, just another suggestion.

Other people have had problems running projects (in another context) where they’ve stored their Documents and Desktop folders containing their projects in iCloud. When you set up the computer, there’s an option to sync these with iCloud. For some reason, Xcode projects held in Documents or Desktop don’t always run.

I’m not sure how to fix that problem, except by creating a folder on the local Mac that isn’t in iCloud and placing the project there.

Interesting point! I don’t keep projects in Dropbox anymore, for similar reasons.

Yes. I bought a new Mac mini on May so I am on the latest of everything.

I have the project local. I suspect the cloud would create problems.

After some thoughts, since I believe on learning by doing, I might Start a new project and type the codes as I move alone through the chapters. I have no rush. It might help me learn better. A silver liner after all.

1 Like

I figure my problem. Choosing the wrong file. Thanks for your replies. By the way, I love the book so far. Now I am :smile:

2 Likes