tags:

views:

1007

answers:

3

I ran into this error when building my code with CLANG:

In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:31,
                 from /Users/waspfish/Documents/NanaimoStudio/Projects/iPhoneMonk/Projects/IdeaOrganizer/IdeaOrganizer_Prefix.pch:13,
                 from :1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollation.h:13: error: syntax error before ‘AT_NAME’ token
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollation.h:21: error: syntax error before ‘}’ token
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollation.h:23: fatal error: method definition not in @implementation context
compilation terminated.
{standard input}:32:FATAL:.abort  detected.  Assembly stopping.

I ended up having to exclude the UILocalizedIndexedCollation.h from UIKit.h and everything built fine. Any idea what could have caused the problem? I can't imagine Apple is shipping a defective header file.

A: 

Usually when I see something like this I clean the build and restart Xcode, then things were fine. With GCC 4.2 sometimes a bad pch could cuase hiccups like this, but clang uses a totoally different pch implementation. You may want t completely delete the build dir while Xcode is not running.

Technically clang is not supported for iPhone development, but I use it for simulator compiles , and I do not see the compile errors you are seeing, so (at least for me) it works. One thing sticks out in my head, you refer to editing your UIKit.h. I understand what you did that, but tweaking system headers is big no-no. Is there a chance you have done that for other reasons, because if you are not running stock headers there any number of reasons this could be happening.

Louis Gerbarg
I removed the builder folder and cleaned all targets and I am still getting the same error. Any idea?
Boon
+6  A: 

The problem comes from SDK 3.0 which now use gcc 4.2 but scan-build still use /usr/bin/gcc. So you need to tell scan-build to use /usr/bin/gcc-4.2 instead.

scan-build --use-cc=/usr/bin/gcc-4.2 xcodebuild -configuration Debug

Et voila!

Djiss
This fixed everything for me. Thanks!
bbrown
good job It works for me also .
hib
This works for me!! Thanks.
Jirapong
+1  A: 

Apple’s engineer had confirmed that they had a bug in UIKit framework:

We do have a simple workaround for this UIKit bug. In UILocalizedIndexedCollation.h change this:

UIKIT_EXTERN @interface UILocalizedIndexedCollation : NSObject
to
UIKIT_EXTERN_CLASS @interface UILocalizedIndexedCollation : NSObject

Denis2342

denis2342