What it is ?

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.

Pre-compiled header files, or PCH files, attempt to address this problem by providing a mechanism for pre-computing and caching much of the work required during the pre-processing phase of compilation.

Xcode

In Xcode, you need to follow two steps :

  1. Add imports of the header files you want in a “prefix header,” and
  • Provide the full path to the “Prefix Header” in “Build Settings” ==> “Apple LLVM Language Section”
  • See the below image, in which i have put the “GoogleAuthentication.pch” file path to “Prefix Header”
  • My file is in the Root of the project. So i have added “GoogleAuthentication.pch”.
    If we have put “GoogleAuthentication.pch” to Any folder named like “Sample” then we have added “Sample/GoogleAuthentication.pch”
  1. Enabling Precompile Prefix Header.
    so they get precompiled. But the idea behind a prefix header is different from precompiling.

A prefix header is implicitly included at the start of every source file. It’s like each source file adds

#import “Prefix.pch”

at the top of the file, before anything else.

Email me when  Jigar M  publishes or recommends stories