Error: syntax error before ‘AT_NAME’ token

I recently ran into this error message within Xcode while writing an iPhone application. I was surprised how long it took to track this down. One of the reasons this is tricky is that message implies that the error occurred in the file referenced in the error message.

For example, in my case, I was looking inside the implementation file (.m) for something obvious to standout.

To get the context of what I am referring to, look at the figure below to see how the message appeared in Xcode on my system:

Xcode Error Message

The crux of the problem was not SomeClass.m, it was one of the .h files imported inside this implementation file that didn’t have a closing @end statement.

Sounds easy enough doesn’t it? Well, most everything is once you’ve found what the problem is. Hopefully this will save you some time if ever encounter this message.

  1. this can also happen when the .h file has a syntax error, such as the last line not having a “;”

  2. This was most helpful. Thank you.

    In my case it was a “;” missing:

    -(void) dealloc


    Best wishes.

Comments are closed.