xcode 添加C文件导致pch错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19723392/
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
Adding C file causes pch error
提问by Alex I
I have an XCode
project with objective-C
files. If I add a new (empty) C file
and try to build, I get a large number of errors right away while building a precompiled header, in ProcessPCH step. The errors are "fatal error: Could not build module 'Foundation'", and things in Foundation.h
not being found. Remove the C file and it builds again. What is going on, and how to fix it?
我有一个XCode
包含objective-C
文件的项目。如果我添加一个新的(空的)C file
并尝试构建,在 ProcessPCH 步骤中构建预编译头时,我会立即收到大量错误。错误是“致命错误:无法构建模块‘基础’”,以及Foundation.h
未找到的东西。删除 C 文件并重新构建。这是怎么回事,如何解决?
(XCode 5.0, OSX 10.8.4)
(XCode 5.0,OSX 10.8.4)
EDITI have tried Clean and Clean build folder, no effect.
编辑我试过清理和清理构建文件夹,没有效果。
EDITSetting Precompile prefix header = No
results in a bunch of syntax errors instead, in stuff like NSObject.h
(and other Foundation framework header).
编辑设置会Precompile prefix header = No
导致一堆语法错误,比如NSObject.h
(和其他 Foundation 框架标头)。
EDITUser Cy-4AH figured it out: there needs to be #ifdef __OBJC__
around the wholepch file.
编辑用户 Cy-4AH 想通了:需要#ifdef __OBJC__
围绕整个pch 文件。
回答by Cy-4AH
Surround #import
's with preprocessor directive #ifdef __OBJC__ #endif
Surround#import
带有预处理器指令#ifdef __OBJC__ #endif