Search code examples
iphonecocoaiospch

<AppName>.pch file usage


What is the importance of .pch file and what is the significance of"#ifdef OBJC"?

Also, where do we define parameters like "#ifdef IS_PRODUCTION" which are checked in .pch file.


Solution

  • .pch is a Pre-Compile Header.

    In the C and C++ programming languages, a header file is a file whose text may be automatically included in another source file by the C preprocessor, usually specified by the use of compiler directives in the source file.

    #ifdef OBJC lets the compiler know that the code is Objective-C.

    #ifdef IS_PRODUCTION is something you have defined on your own, a directive telling the compiler to do something only if this is defined, most-likely something for a PRODUCTION build.