Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode "Use of undeclared identifier" errors, compiles/runs just fine

I've got an incredibly annoying issue that is hampering my workflow. In my project I have "User of undeclared identifier" errors all over. They are all in reference to a single class, specifically a Theme class. I checked for any circular referencing with my imports, none. I'm really confused.

Here is a screenshot of the errors. I would post errors in the Build Log for more detail, but there aren't any. It builds and runs just fine...

enter image description here

I've tried cleaning, deleting the derived data... Any ideas?

like image 626
rnystrom Avatar asked Aug 27 '12 21:08

rnystrom


People also ask

How do you solve undeclared identifier?

To solve it simply declare i outside the loop so that the whole program inside the main function can use it. LIBRARY NOT INCLUDED: If we try to use a data type such as vector without including its library we will get this error. To fix this, make sure that you are using an identifier only after including its library.

What does the error message undeclared identifier possible mean?

The identifier is undeclaredIf the identifier is a variable or a function name, you must declare it before it can be used. A function declaration must also include the types of its parameters before the function can be used.

What does undeclared identifier mean in C++?

Undeclared Identifier in C++ Errors Undeclared identifier error is thrown by the compiler to indicate that it can't find a declaration for some identifier.


2 Answers

I was having the same problem and noticed that all of the undeclared identifiers were declared in files that were in my pch file.

With this in mind I deleted one of the #import lines from the pch file and recompiled which failed as expected. I then put the deleted line back in, recompiled and it compiled normally with all the false errors gone.

Hopefully this simple solution helps a few of you out if the above solutions don't.

like image 64
Newtz Avatar answered Oct 06 '22 01:10

Newtz


These kinds of errors are quite common with Xcode, unfortunately. It would be great if it would auto-refresh its error list all the time, but it doesn't always. When this happens, I strongly suggest that you restart Xcode, which will flush its error cache and hopefully solve your issues.

like image 40
Richard J. Ross III Avatar answered Oct 06 '22 00:10

Richard J. Ross III