Cannot find ContentView in scope

IOS Foundations (SwuftUI) course Module 2 Lesson 7 MVVM Architecture Pattern.

Xcode ver 12.5.

Issues:

  1. Cannot find ContentView in scope. Build fails. Tried solution on forum; did not work.Tried Chris’ idea in lesson; did not work.

  2. Folders Views, Models, and ViewModels do not have auto-complete or code coloring.

How are these issues resolved? I’m stuck!

Thanks for any help.

Sounds like a typo or missing bracket. Post your code here, so we can have a look.

When you created the project did you create it as a SwiftUI project or as a Storyboard project?

Can you post a screen shot of the left hand panel for your project where all the files and folders are displayed?

Mr. Parker,

Thanks for your reply to my inquiry. The issues have been resolved. To view project, simply watch Lesson 7 MVVM Architecture Pattern in Module 2 of IOS Foundations (SwiftUI). You will see that Chris Ching encounters the ‘Cannot find ContentView in scope’ error. He remarks ‘Xcode gets confused…’. He suggests building project and does so with success. He further suggests running it in simulator if issue still exists. When I tried that for the first time, the build failed.

Eventually, I deleted project and started over. I still got the ‘Cannot find ContentView in scope’ error, but build worked. Success!

In my opinion, this is a bug in Xcode.

Thanks for your help.

Jeff Parker

There could be a number of reasons that Xcode is having a whammy and saying that it can’t find ContentView in scope or throwing up strange errors.

  • You might need to clean the Build folder, ie, use the keyboard shortcut Shift + Command + K or via the Menu “Product > Clean Build Folder”
  • You might need to restart Xcode.
  • You might need to restart your Mac

It’s a monster of a program so don’t be surprised if it gets it’s knickers in a knot at times.