syntax error before ‘AT_NAME’ token
If you happen to be using Xcode and get this somewhat baffling error message when building:
syntax error before ‘AT_NAME’ token
The problem is that you are missing an @end in some file that you’ve #imported, probably a header file. This error also shows up as “parse error ...” in some versions of Xcode (took me a while to track down with Google as a result).
Thanks you saved me some pain! I’ve new to Xcode and its great to have practical tips like this recorded somewhere.
December 8, 2007 @ 10:20 pm
It could be caused by something niggly like this!
- (CGRect)xyz // <- no ; !
@end
December 16, 2007 @ 9:33 am
Since that last comment isn’t very clear, and I just had to figure it out for myself…
This error can also happen if you miss out a semicolon before a @whatever expression.
For example
…
- (void)draw;
- (void)startRotate // note missing semicolon
@end
July 23, 2008 @ 5:13 pm
A missing close brace for an if statement inside a function can also cause this problem.
If you use XCode to re-indent your source file (Edit -> Format -> Re-Indent) you’ll be able to see fairly easily if you’re missing something like a ; or }.
September 4, 2008 @ 5:42 pm
I just had the same error message – found out it was because I’d hit Cmd-s (tried to hit) quickly to save a file but hadn’t – insted I’d inserted a letter ’s’ in my file just below the opening comment block.
I didn’t see this for quite a while, this link helped me track it down though
October 14, 2008 @ 6:36 pm
Thanks for the tips!
October 21, 2008 @ 6:31 pm
Got this bug. Pretty dumb and primitive. I miss Java !
November 25, 2008 @ 9:54 pm
Its the post that keeps on giving!
thx
December 5, 2008 @ 1:03 pm
Is there a lint program for Objective C? Finding these by hand is easy for a syntax checker but a huge hassle for a human
March 28, 2009 @ 8:26 pm
I’m not sure. I’ve never found one.
April 13, 2009 @ 10:28 am
Thanks for this, it’s really saved me a headache!
I went from 38 errors & 5 warnings to Build Succeeded straight off!
Winner!
April 16, 2009 @ 7:01 am
Thanks for the pointer
After 15 minutes of pain and frustration, finally found the line missing the “;” just before @end ! Sigh…
April 29, 2009 @ 2:01 pm
Ok my turn with this fun and exciting message.
Turns out my problem was having @class ClassName in a header file as well as importing the ClassName.h file. Obviously a trap for young players.
9 errors and 2 warnings to perfect build…
June 21, 2009 @ 11:01 pm
Also, got this error when the cache was corrupted.
Indicated the error was coming from a UIKit header in the cache
(Xcode 3.1.1)
Go to the the following menu:
Xcode -> Empty Caches
July 22, 2009 @ 4:07 pm
Still, building in Simulator 3.0 with this error and building in Simulator 3.1 without, makes me think there is a bug in the 3.0 API in my case
March 19, 2010 @ 4:16 pm