1、先创建 pch 文件

2、在工程的 Targets 里面的 Building Setting 中搜索 Prefix Header ,然后把 Precompile Prefix Header 右边的 No 改为 YES,预编译后的pct文件会被缓存起来,可以提高编译速度。
3、设置pch文件的路径,将pch文件拖进下图弹出的框里面,pch的文件路径就会被填进去,但是这是绝对路径,如果你把项目移到另外一个地方,就会报错,找不到pch文件,所以需要把它转为相对路径,绝对路径格式:/Users/lixue/Desktop/项目名/项目名/PrefixHeader.pch,转化为相对路径,如下格式$(SRCROOT)/项目名/PrefixHeader.pch(注意这里只有一个项目名)

网友评论