修改默认的 -Prefix.pch 文件 [英] Modifying the default -Prefix.pch file

查看:24
本文介绍了修改默认的 -Prefix.pch 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何修改包含在 xcode 项目模板中的默认 .pch 文件.

I would like to know how I can modify the default .pch file included with the xcode project templates.

我想这样做是为了在我的所有项目中自动包含一些#defines.对于共享应用程序委托,我希望为所有项目提供的示例类似于以下内容:

I would like to do that in order to have a few #defines automatically included in all my projects. An example of what I would want to have for all my projects is something like the following for a shared app delegate:

#define APP_DELEGATE ((AppDelegate*)[[UIApplication sharedApplication] delegate])

我尝试在 xcode 的包中搜索模板 .pch 文件,但没有成功.

I tried searching for a template .pch file within xcode's package with no luck.

如果您认为这样做不是一个好主意,请随时告诉我原因,但如果可以,也请告诉我如何修改模板,因为这是我的问题.

If you think it is not a good idea to do this, feel free to tell me why, but please also tell me how I can modify the template if you can, since that is my question.

推荐答案

默认的 Xcode 模板位于 /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates .在 Base/Base.xctemplate 中,您将找到一个文件 TemplateInfo.plist .这就是你必须修改才能做你想做的事情.查看该 plist 的定义部分.

The default Xcode templates live in /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates . Inside Base/Base.xctemplate you will find a file TemplateInfo.plist . That is what you will have to modify to do what you want. Look at the Definitions section of that plist.

如果您只想为 iOS 执行此操作,则需要修改 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates 中的模板.iPhone Base.xctemplate 的结构虽然不会让更改 iOS 的默认前缀头变得容易.

If you want to do this only for iOS, you will instead need to modify the templates in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates. The structure of the iPhone Base.xctemplate though would not make changing the default prefix header for iOS only easy though.

XCode 模板曾经很容易使用和创建,从 XCode 4 开始就不是这样了.

XCode templates were once straightforward to use and create, since XCode 4 this has not been the case.

我强烈建议您参考网上关于创建自己的模板的一些信息,而不是修改 Xcode 中的模板.

I would strongly suggest following some of the information online about creating your own templates instead of modifying those inside Xcode.

这是创建自己的模板和了解模板工作原理的最佳起点之一

这篇关于修改默认的 -Prefix.pch 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆