Xcode shows many errors but program compiles and runs fine (in both simulator and device)

After installing the CocoaLumberjack' log compressor class I've been getting this annoying behavior: Xcode complains that there are many undeclared identifiers and gives me many errors (not warnings but errors with the red icon).

The thing is that I can compile and run my iPad app just fine but Xcode won't do any autocompletion. I tried cleaning the build folder (Product > option + Clean), and also deleting derived data. I've also rebooted to no avail.

As you can imagine this is a pain to work with. I did have this behavior happen before on a previous version of Xcode; it had something to do with stuff in my precompiled headers file but using the solution above would always fix it. I'm currently using Xcode 4.4 (4F250).

Sample error I'm getting:

Semantic Error: use of undeclared identifier 'DDTTYLogger'

The above happens even with classes that I wrote myself and that have not changed since installing the CocoaLumberjack compressor class.


Solution 1:

I finally solved this after MANY attempts using the following:

Remove the last #import from my Prefix.pch and build again. Errors would happen (obviously). Put the line back and build again. No errors would show and after 10 seconds or so, errors would come back again.

Repeat the above except instead of the last #import, remove the last TWO imports, then three, four, etc. I did this until I removed five imports and when I put them back and waited, Xcode stopped complaining.

Note that this didn't occur to me at all. I read this solution on a blog somewhere.

Weird bug...

Solution 2:

Open build settings and set "Precompile Prefix Header" to "No", that solved my problem.

Kudos for: https://stackoverflow.com/a/7035492/936957