jwknz
jwknz

Reputation: 6822

Cannot find TestView in scope

I am seeing the following error in iOS14, I am not sure if it is a bug or a user error :-) I appreciate it is still in beta, so I will post this in the developer forums as well.

I am seeing the following error come up when I make a macOS app in SwiftUI - when I create the same as an iOS app, the error does not appear.

Do I need to do something special for macOS apps when it comes to importing SwiftUI modules?

enter image description here

enter image description here

Upvotes: 23

Views: 29067

Answers (7)

levi
levi

Reputation: 11

Had this today, but found that I renamed my file's name but I forgot to rename the corresponding struct within it. That fixed my issue.

Upvotes: 1

PHANTOM-X
PHANTOM-X

Reputation: 586

You need to make sure that you've selected "Create folder references" when adding a new file to the project.

enter image description here

Upvotes: 0

Hashim Akhtar
Hashim Akhtar

Reputation: 881

In my case the reason was that the protocol I was inheriting in the class, needed to be made public.

Upvotes: 3

Debra
Debra

Reputation: 1

When you rename a swift View from Project navigator or refactor the name within a struct, check that the struct and preview name were updated accordingly.

Upvotes: 0

Tai Le
Tai Le

Reputation: 9286

Don't forget to add it to your Target Membership

enter image description here

Upvotes: 10

Kacy
Kacy

Reputation: 3430

Had this issue today because I renamed the file that contained the class. The solution was to delete the file and recreate it.

Upvotes: 11

Rajan Twanabashu
Rajan Twanabashu

Reputation: 4726

  • Clean the project
  • Close and relaunch the Xcode

This will solve the problem.

Upvotes: 3

Related Questions