日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

XCode6 生成prefix.pch文件

發(fā)布時(shí)間:2025/3/20 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 XCode6 生成prefix.pch文件 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>

在Xcode6之前,新建一個(gè)工程的時(shí)候,系統(tǒng)會(huì)幫我們自動(dòng)新建一個(gè)以工程名為名字的 pch (precompile header)文件,在開發(fā)過程中,可以將那些整個(gè)工程都廣泛使用的頭文件包含在該文件下,編譯器就會(huì)自動(dòng)的將pch文件中的頭文件添加到所有的源文件中 去,這樣在需要使用相關(guān)類的時(shí)候不需要使用import就可以直接使用頭文件中的內(nèi)容,很大程度上帶來了編程的便利性,但潛在的也帶來了一些問題,這也是 在Xcode6中默認(rèn)不再創(chuàng)建pch的原因吧。

關(guān)于pch的得與失,stackoverflow上有段話講的比較透徹:http://stackoverflow.com/questions /24158648/why-isnt-projectname-prefix-pch-created-automatically-in-xcode-6

?

As to where to put code that you would put in a prefix header, there is no code you should put in a prefix header. Put your imports into the files that need them. Put your definitions into their own files. Put your macros...nowhere. Stop writing macros unless there is no other way (such as when you need?__FILE__). If you do need macros, put them in a header and include it.

The prefix header was necessary for things that are huge and used by nearly everything in the whole system (like?Foundation.h). If you have something that huge and ubiquitous, you should rethink your architecture. Prefix headers make code reuse hard, and introduce subtle build problems if any of the files listed can change. Avoid them until you have a serious build time problem that you can demonstrate is dramatically improved with a prefix header.

In that case you can create one and pass it into clang, but it's incredibly rare that it's a good idea.

?

但有些時(shí)候,還是需要pch文件的,那么怎么在Xcode6中添加一個(gè)pch文件呢?

首先,Command+N,打開新建文件窗口:ios->other->PCH file,創(chuàng)建一個(gè)pch文件,添加需要引入的頭文件名:

?

?

其次,修改工程配置文件,將剛剛創(chuàng)建的PCH file的路徑添加到building setting中的precompile header選項(xiàng)中去,注意debug和release兩欄都要添加:

?

?

至此,大功告成,編譯一遍,新添加的pch文件就可以正常使用了^_^。


轉(zhuǎn)載于:https://my.oschina.net/u/2361492/blog/603031

總結(jié)

以上是生活随笔為你收集整理的XCode6 生成prefix.pch文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。