ios Xcode 6 - 未知类型名称“NSString”/预期标识符或“(”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26003727/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 6 - Unknown type name 'NSString' / Expected identifier or '('
提问by GangstaGraham
When I am running my project in Xcode 6, I am having many weird errors.
当我在 Xcode 6 中运行我的项目时,我遇到了许多奇怪的错误。
Parse Issue - Unknown type name 'NSString'
Format argument not an NSString
Could not build module Foundation
Could not build module QuartzCore
All of these errors occur in Apple's header files such as: CAMediaTiming.h, NSObjCRuntime.h,NSZone.h,NSObject.h, CALayer.h, etc.
所有这些错误都出现在 Apple 的头文件中,例如:CAMediaTiming.h、NSObjCRuntime.h、NSZone.h、NSObject.h、CALayer.h 等。
Unfortunately, the answers in here: ios - Parse Issues in NSObjCRuntime, NSZone, and NSObjectdid not work for me.
不幸的是,这里的答案:ios - Parse Issues in NSObjCRuntime、NSZone 和 NSObject对我不起作用。
How do you recommend I fix these errors?
您建议我如何修复这些错误?
回答by GangstaGraham
The problem was that I had some .c
files in my project, apparently Xcode 6 doesn't like .c
files.
问题是.c
我的项目中有一些文件,显然 Xcode 6 不喜欢.c
文件。
I changed the extension of the .c
files to .m
and Xcode 6 is happy again!
我将.c
文件的扩展名更改为.m
Xcode 6 又开心了!
回答by olynoise
You can get this error if you have a PrefixHeader file that imports Objective-C code and also some plain C files in your project, because the C files try to import the Objective-C.
如果您有一个 PrefixHeader 文件导入了 Objective-C 代码以及项目中的一些普通 C 文件,您可能会收到此错误,因为 C 文件尝试导入 Objective-C。
To fix, wrap your objective-c imports like this :
要修复,请像这样包装您的objective-c 导入:
#ifdef __OBJC__
#import <OOObjectiveCClass.h>
#endif
回答by Omar Rehman
See if the Prefix Header file path is correctly placed under Build Settings tab. See the complete answer at the following link.
查看 Prefix Header 文件路径是否正确放置在 Build Settings 选项卡下。请参阅以下链接中的完整答案。
回答by sailor
I use Xcode 8.3.3,I also encounter this problem,and I solve this issue by selecting the file and in the right panel in Xcode in the Identity and Type part choose Type to Objective-C++.
我使用Xcode 8.3.3,我也遇到了这个问题,我通过选择文件并在Xcode右侧面板的Identity and Type部分选择Type to Objective-C++来解决这个问题。
回答by Jeff Grimes
You can also try deleting the Samples folder in the FacebookSDK folder (and then deleting the reference to it in Xcode.
您还可以尝试删除 FacebookSDK 文件夹中的 Samples 文件夹(然后在 Xcode 中删除对它的引用。