S R Nayak S R Nayak - 2 months ago 7
iOS Question

What is Prefix.pch file in Xcode?

So many developers are adding various convenience macros to the

Prefix.pch
. But my question is what is that
Prefix.pch
file.


  • If i remove that
    Prefix.pch
    file from my
    Xcode
    , then will my application run? Or will it show any error? Or will it crash during build?

  • How can i run my application without
    Prefix.pch
    file


Answer

Precompiled header.

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.

Xcode

In Xcode, you add imports of the header files you want in a “prefix header,” and 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.

Removing it.

You can remove the precompiled header. This question has been already answered in thread I'm linking below. It contains all the information you need as well as useful comments.

Is it OK to remove Prefix.pch file from the Xcode project?