Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

importance of <ApplicationName>_prefix.pch file

Tags:

ios

cocoa

iphone

What is the importance of importance of _prefix.pch file?

like image 440
Abhinav Avatar asked Jan 13 '11 02:01

Abhinav


People also ask

What is Prefix PCH?

Prefix. 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 add PCH files to Xcode?

From your Xcode menu, select File > New > File... From iOS template options, select Other > PCH file. Name the file <target_name>-Prefix. pch, and then select Create.


1 Answers

Conceptually, it's included at the top of every translation unit (i.e. every compiled C, C++, Objective-C, or Objective-C++ file.) So you can force every file in your project to include a particular macro by adding this to your .pch file:

#if !defined(MY_MACRO)
    #define MY_MACRO (12345)
#endif /* !defined(MY_MACRO) */

And then MY_MACRO is always available. It's also commonly used to import framework headers so you don't have to run around typing #import <Foundation/Foundation.h> in every file.

like image 146
Jonathan Grynspan Avatar answered Sep 19 '22 13:09

Jonathan Grynspan