
例如,标题下方需要大多数文件
#import <UIKit/UIKit.h> #import <Foundation/Foundation.h>
因此,不是每个文件都应该有,在.pch文件中添加这些文件是不错的做法?
.pch文件
#ifdef __OBJC__ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import <MostlyUsed.h> #endif
我发现了一些这样的缺点,
1)依赖隐藏.
2)源文件无法直接复制.
如果你们提供一些意见,这将是很好的.
谢谢
解决方法 是的,你可以做到.即使它减少了编译时间.
In Objective-C,importing same headers in every class make compile time longer?的摘录
总结In general,newly-generated iOS projects come with this functionality,
which is called a @R_248_3013@ header or prefix header,and is a file
that has the extension .pch.You can throw all the headers you want in there and Xcode will
pre-compile it before it builds anything else,and use it to compile
the other compilation units in your project (e.g. .m files).Using a @R_248_3013@ header may or may not increase compile time; in
general,it reduces compile time,as long as you have a lot of common
headers and/or a lot of source files.However,it’s not necessarily good practice to treat the pre-compiled header like a big dumPing ground,as your compilation units can form implicit dependencIEs on all sorts of stuff when you may want to enforce loose coupling between components.
以上是内存溢出为你收集整理的ios – 包括.pch文件中的公共头文件全部内容,希望文章能够帮你解决ios – 包括.pch文件中的公共头文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)