xcode6如何添加并配置pch文件
来源:互联网 发布:创维网络机顶盒e900 编辑:程序博客网 时间:2024/06/06 19:47
1. 在Xcode6之前,新建一个工程的时候,系统会帮我们自动新建一个以工程名为名字的pch (precompile header)文件;
2. pch文件用途:在开发过程中,可以将那些整个工程都广泛使用的头文件包含在该文件下,编译器就会自动的将pch文件中的头文件添加到所有的源文件中去,这样在需要使用相关类的时候不需要使用import就可以直接使用头文件中的内容,很大程度上带来了编程的便利性;
3. 问题:但潜在的也带来了一些问题,这也是在Xcode6中默认不再创建pch的原因吧。
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.
(翻译:
在那里,把你的代码将在一个前缀标题,没有代码应该放在一个前缀的头。把你的输入需要的文件。把你定义为自己的文件。把你的宏……一事无成。停止写作宏除非没有其他的方式(比如当你需要__file__)。如果你需要的宏,放在一个标题,包括它。
前缀标题的东西是巨大的,几乎在整个系统中所用的一切东西都是必要的(如基础。H)。如果你有巨大的和无处不在的,你应该重新考虑你的建筑。前缀标题使代码重用困难,并介绍了微妙的构建问题如果列出的文件可以改变。避免他们直到你有一个严重的建造时间问题,你可以证明是一个前缀报头大幅改善。
在这种情况下,你可以创建一个并把它传递到铿锵,但它是非常罕见的,这是个好主意。
)但有些时候,还是需要pch文件的,那么怎么在Xcode6中添加一个pch文件呢?
首先,Command+N,打开新建文件窗口:ios->other->PCH file,创建一个pch文件,添加需要引入的头文件名:
其次,修改工程配置文件,将刚刚创建的PCH file的路径添加到building setting中的precompile header选项中去,注意debug和release两栏都要添加:
在TARGETS-》bundle setting-》
完成。
- xcode6如何添加并配置pch文件
- Xcode6如何添加pch文件
- XCode6 如何添加.pch文件
- 基本配置之(Xcode6之后如何添加.pch文件)
- xcode6中如何添加pch文件
- xcode6中如何添加pch文件
- Xcode6中如何添加pch文件
- xcode6中如何添加pch文件
- Xcode6中如何添加pch文件
- xcode6中如何添加pch文件
- xcode6中如何添加pch文件
- xcode6中如何添加pch文件
- xcode6中如何添加pch文件
- Xcode6中如何添加pch文件
- Xcode6中如何添加pch文件
- xcode6中如何添加pch文件
- xcode6中如何添加pch文件
- Xcode6中如何添加pch文件
- 神经网络总结
- 总结之java
- Android 内存溢出问题
- Eclipse设置:背景与字体大小和xml文件中字体大小调整
- MARYLAND/Software Security 摘要与感悟(4)
- xcode6如何添加并配置pch文件
- 装饰设计模式、LineNumberReader
- 从字串的单词倒序算法到C#字串处理
- java基础-finally块对return变量的影响分析
- CodeBlocks暴力恢复默认设置
- 黑马程序员---oc copy
- excle计算两个日期相差天数
- Linux-权限管理-chattr与lsattr命令
- 脑洞大开的思维工具:PMI