CLANG gives errors complaining about defective UILocalizedIndexedCollation.h header file

I ran into this error while creating my code using 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 context
 compilation terminated.
 {standard input}: 32: FATAL: .abort detected.  Assembly stopping.

In the end, I had to exclude UILocalizedIndexedCollation.h from UIKit.h and everything was built perfectly. Any idea what might cause the problem? I can not imagine that Apple is sending a defective header file.

+4
source share
3 answers

The problem comes from the SDK 3.0, which now uses gcc 4.2, but scan-build still uses / usr / bin / gcc. So you need to say scan-build instead of / usr / bin / gcc -4.2.

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

Et voila!

+7
source

The apple engineer confirmed that they had an error in the UIKit framework:

We have an easy way around this UIKit error. In UILocalizedIndexedCollation.h, change this:

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

Denis2342

+2
source

Usually, when I see something like this, I clean the assembly and restart Xcode, then everything was fine. With GCC 4.2, sometimes a bad pch might hide hiccups like this, but clang uses totoally different pch implementations. You can completely delete the build file until Xcode is running.

Technically, clang is not supported for iPhone development, but I use it to compile simulations, and I don't see the compilation errors you see, so (at least for me) this works. One thing sticks out in my head, you are linking to editing your UIKit.h. I understand that you did this, but setting the system headers is a big question, no. Is there a chance that you did this for other reasons, because if you do not use stock headers, there are several reasons why this can happen.

0
source

All Articles