Prefix.pch file

看到.pch文件,有一种很生疏的感觉,第一印象根据后缀.pch猜测,还以为是patch的缩写,莫非是什么补丁包?基于不胡乱猜的精神,google了一下,还真不是这个意思,事实证明这是个预编译头文件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


这里是原始网址:What is Prefix.pch file in Xcode?

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,562评论 5 6
  • 去了一趟菜市场,买了俩萝卜,便宜又美味。 其实在我的记忆里,我是对萝卜致谢不敏的。原因是在家里冬天,可以常常吃到它...
    碎沫阅读 535评论 8 1
  • 必须把最宝贵的的注意力放在你自己身上,请不要莫名其妙的凑热闹、心急火燎的随大流、操碎了别人的心。把你的注意力放在你...
    晓灿辰依阅读 213评论 0 1
  • 许一季花开,淡淡馨香弥散在梦里梦外,沉醉不愿醒来。 挽一帘春色,簌簌花影洒落在青石窗台,风儿抚尽尘埃。 书一世绝恋...
    静如流水阅读 225评论 0 0
  • 站在人多的地方自我放生
    子清阅读 304评论 0 1