XCode在* prefix.pch中找不到#define宏但编译好了

时间:2013-07-16 04:26:06

标签: xcode macros precompiled-headers pch

我在-prefix.pch文件中添加了一些东西,但是XCode在我使用它时给了我错误,说

  

使用未定义的标识符......

但是如果我编译它(Command + B),它编译,所以我认为它是由派生数据引起的,然后我试图删除派生数据(从而迫使它再次重新生成)但是在Organizer那里该项目没有派生数据,我也尝试过Clean但不起作用。

有人可以帮忙吗?

编辑:我定义的宏对于这个问题并不重要,但这里是宏:

#define IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

编辑2:我将Kiwi作为单元测试工具添加到项目中,可能是项目设置中的某些内容发生了变化而导致了问题。

2 个答案:

答案 0 :(得分:0)

You will need to include inly framework related headers and also adding header in pch file means you need not import that header in any of the file in your project.
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iOS SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

答案 1 :(得分:0)

as bbum说

  

Ewww ...不要将宏放在.pch文件中!根据定义,.pch文件是项目特定的预编译头。它确实不应该在项目的上下文之外使用,除了#includes和#imports 1

之外它实际上不应该包含任何内容。

可能有帮助

相关问题