Iphone CLANG给出错误,抱怨头文件UILocalizedIndexedCollation.h有缺陷

Iphone CLANG给出错误,抱怨头文件UILocalizedIndexedCollation.h有缺陷,iphone,clang,Iphone,Clang,我在使用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

我在使用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. 在/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/ideaoorganizer/ideaoorganizer_Prefix.pch:13, 发件人:1: /开发者/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollation.h:13:错误:“AT_NAME”标记前的语法错误 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollation.h:21:错误:“}”标记前的语法错误 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollation.h:23:致命错误:方法定义不在@implementation上下文中 编译终止。 {标准输入}:32:致命:。检测到中止。集合停止。
我最终不得不从UIKit.h中排除UILocalizedIndexedCollation.h,并且一切都很好。知道是什么导致了这个问题吗?我无法想象苹果会提供一个有缺陷的头文件。

通常当我看到这样的东西时,我会清理构建并重新启动Xcode,然后一切都会好起来。在GCC4.2中,有时一个糟糕的pch可能会导致这样的问题,但是clang使用了完全不同的pch实现。您可能不希望在Xcode未运行时完全删除build dir


从技术上讲,iPhone开发不支持clang,但我使用它进行模拟器编译,我看不到您看到的编译错误,所以(至少对我来说)它可以工作。有一件事在我脑海中浮现,你指的是编辑你的UIKit.h。我知道你是怎么做的,但是调整系统标题是一个大问题。你有没有可能因为其他原因这样做,因为如果你没有运行股票标题,有很多原因可能会发生这种情况。

问题来自SDK 3.0,它现在使用gcc 4.2,但扫描构建仍然使用/usr/bin/gcc。因此,您需要告诉scan build改用/usr/bin/gcc-4.2

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

苹果的工程师已经确认他们在UIKit框架中有一个bug:

对于这个UIKit错误,我们有一个简单的解决方法。在UILocalizedIndexedCollation.h中,更改以下内容:

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

Denis2342

我删除了builder文件夹并清理了所有目标,但仍然收到相同的错误。有什么想法吗?这帮我解决了所有问题。谢谢