我在使用 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.
我最终不得不从 UIKit.h 中排除 UILocalizedIndexedCollation.h,一切都构建得很好。知道是什么导致了这个问题吗?我无法想象 Apple 会发布一个有缺陷的头文件。
最佳答案
问题来自 SDK 3.0,现在使用 gcc 4.2,但 scan-build 仍然使用/usr/bin/gcc。所以你需要告诉 scan-build 使用/usr/bin/gcc-4.2 代替。
scan-build --use-cc=/usr/bin/gcc-4.2 xcodebuild -configuration Debug
瞧瞧!
关于iphone - CLANG 给出错误,提示头文件有缺陷 UILocalizedIndexedCollation.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1078001/