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