Prefix.pch file

看到.pch文件,有一種很生疏的感覺,第一印象根據(jù)后綴.pch猜測(cè),還以為是patch的縮寫,莫非是什么補(bǔ)丁包?基于不胡亂猜的精神,google了一下,還真不是這個(gè)意思,事實(shí)證明這是個(gè)預(yù)編譯頭文件Pre-Compile Header

答案來源于偉大的stackoverflow,以下是引用:

What is Prefix.pch file?

.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.

Prefix headers are compiled and stored in a cache, and then automatically included in every file during compilation. This can speed up compilation, and lets you include a file without adding an import statement to every file using it. They are not required, and actually slow compilation whenever you change them.

Yes, you can compile and run the project without .pch file

In Xcode, go to your target's build settings (Command-Option-E, build tab) and uncheck Precompile Prefix Header (GCC_PRECOMPILE_PREFIX_HEADER). You can also remove the value of the Prefix Header setting if you wish.

Also note that,

Don't put macros in a.pch file! A .pch file is, by definition, a project specific precompiled header. It really shouldn't be used beyond the context of the project and it really shouldn't contain anything but #includes and #imports.

If you have some macros and such that you want to share between headers, then stick 'em in a header file of their own — Common.h or whatever — and #include that at the beginning of the .pch


這里是原始網(wǎng)址:What is Prefix.pch file in Xcode?

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,655評(píng)論 5 6
  • 去了一趟菜市場(chǎng),買了倆蘿卜,便宜又美味。 其實(shí)在我的記憶里,我是對(duì)蘿卜致謝不敏的。原因是在家里冬天,可以常常吃到它...
    碎沫閱讀 567評(píng)論 8 1
  • 必須把最寶貴的的注意力放在你自己身上,請(qǐng)不要莫名其妙的湊熱鬧、心急火燎的隨大流、操碎了別人的心。把你的注意力放在你...
    曉燦辰依閱讀 222評(píng)論 0 1
  • 許一季花開,淡淡馨香彌散在夢(mèng)里夢(mèng)外,沉醉不愿醒來。 挽一簾春色,簌簌花影灑落在青石窗臺(tái),風(fēng)兒撫盡塵埃。 書一世絕戀...
    靜如流水閱讀 265評(píng)論 0 0
  • 站在人多的地方自我放生
    子清閱讀 340評(píng)論 0 1

友情鏈接更多精彩內(nèi)容