I am facing a strange error when writing the simplest of swift programs in Xcode 12.0.1.
It says that it can’t find T1 in scope when it is very much in scope. I feel that it must be trivial to solve this problem, and I tried ⌘ + ⇧ + K and closed Xcode and reopened, but the problem persists. Anyone knows how this can be solved?
2
Answers
Sometimes there are ghost errors that seem to not go away, even when Xcode is closed and reopened, but are fixed by either changing the code then changing it back, or clicking build anyway and the build succeeds.
Otherwise, the color highlighting of
T1
in the return doesn’t match in the variable declaration. That suggests name clashing. Are there any types or global variables calledT1
, even if there’s nothing else in your code maybe it’s a built-in type or similar? Try naming the variable differently.I got the same error and was searching around, but couldn’t find an answer to it so I’ll share it here for others to find as well. For my part, I was creating a view in a package and was referencing that view from an app.
I got the
Cannot find [Type] in scope
and turns out I forgot to put thepublic
attribute on the view struct.