What is Prefix.pch file in Xcode?

后端 未结 4 575
别那么骄傲
别那么骄傲 2020-12-02 06:50

So many developers are adding various convenience macros to the Prefix.pch. But my question is what is that Prefix.pch file.

  • If i

4条回答
  •  孤街浪徒
    2020-12-02 07:08

    History:

    #include => #import => .pch
    

    #include vs #import

    Precompiled Headers - prefix.pch

    #include vs @import has a disadvantage - slow build time because a compiler must parse and compile as many times as many .h files were imported.

    Precompiled header file - .pch - collects the common headers. When this file is precompiled ones it can be used in source files which speeds up a build time.

    Let's take a look at Prefix.pch sample:

    #ifdef __OBJC__
        #import 
        #import 
    #endif
    

    To add .pch file go to Build Settings:

    Developer has to manage .pch file that imposes additional costs for supporting it.

    The next step is @import[About]

提交回复
热议问题