Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a precompiled header file to my ios project?

I'm looking to create a precompiled header file, to avoid having to include the same debug and tracking libraries in every header in the project.

I've created a file called -Prefix.pch:

#ifdef __OBJC__
#import "Blah.h"
#import "Blarg.h"
#endif

and added it to the project. Is there anything more I'm supposed to do, or should things just work now (assuming I do a project clean and recompile)?

like image 648
blueberryfields Avatar asked May 16 '12 15:05

blueberryfields


People also ask

What is PCH file in iOS?

pch is a precompiled header. Precompiled headers were invented to make compiling faster. Rather than parsing the same header files over and over, these files get parsed once, ahead of time.

How do I create a precompiled header in Visual Studio?

Configure Visual Studio to create precompiled headerschoose "All Configurations", then go to C/C++ -> Precompiled Headers, choose "Create Precompiled Header", make sure stdafx. h is the header file to use, and leave the rest to the default value.


1 Answers

Set the target's build settings as follows:

GCC_PRECOMPILE_PREFIX_HEADER=YES
GCC_PREFIX_HEADER="Prefix.pch"

Note that you can plop these keys in the Build Settings search field, if you prefer to use Xcode's UI for your build settings.

like image 140
justin Avatar answered Oct 11 '22 19:10

justin