[ View menu ]

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).

5 Comments

  1. Matthew Hall says:

    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

  2. Mathieu says:

    It could be caused by something niggly like this!

    - (CGRect)xyz // <- no ; !

    @end

    December 16, 2007 @ 9:33 am

  3. Laurie says:

    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

  4. Rob Drimmie says:

    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

  5. Darren says:

    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

RSS feed Comments | TrackBack URI

Write Comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>