3

I've added something in -prefix.pch file, but XCode gives me error when I use it, saying

Use of undefined identifier ...

However if I compile it (Command+B), it compiles, so I thought it was caused by derived data, I then tried to remove derived data (thus to force it to be re-generated again) but in Organizer there was NO derived data for the project, I also tried Clean but does not work.

Can anyone help?

edit: the macro I defined is not important for the question, but here is the macro:

#define IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

edit 2: I added Kiwi as unit test tool to the project, probably something in project settings are changed which caused the problem.

hzxu
  • 5,753
  • 11
  • 60
  • 95

2 Answers2

1

as bbum says

Ewww… don't put macros in a .pch file! A .pch file is, by definition, a project specific precompiled header. It really shouldn't be used beyond the context of the project and it really shouldn't contain anything but #includes and #imports1

may be this helps

Community
  • 1
  • 1
mirror
  • 345
  • 3
  • 10
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
NHS
  • 409
  • 2
  • 7
  • Yes I did that, say if you `#define MYNUM 0` in the pch file, then use `MYNUM` somewhere else, XCode tells me it cannot find `MYNUM`, but when I compile, it works and the app runs. – hzxu Jul 16 '13 at 05:21
  • 1
    create one .h file as commonmacros.h and add your macro in that and just import that commonmacros.h header in the class you are using – NHS Jul 16 '13 at 06:30