在每个项目的基础上定义新的 XCode 模板标签

发布于 2024-10-21 09:14:23 字数 578 浏览 4 评论 0原文

众所周知,您可以定义新文件模板中使用的标签的值,如 http:// /cocoadev.com/index.pl?ProjectBuilderTips

因此,典型的模板如下所示:

/*
 *  main.m
 *  «PROJECTNAME»
 *
 *  Created by «FULLUSERNAME» on «DATE».
 *  Copyright (c) «YEAR» «ORGANIZATIONNAME». All rights reserved.
 *
 */

现在,我知道如何定义新模板并且已经这样做了。但是,我希望我的新模板在其中使用我自己的新标签,如下所示:

/*
 *  «ATTRIBUTIONLINE»
 */

...并且我希望该标签可以在每个 XCode 项目的基础上定义。这可能吗?我进行了搜索,只能找到有关在命令行上运行某些内容的常用内容,这些内容为所有项目定义了众所周知的标签。

It's well known that you can define the values for tags that are used in new file templates, as described at http://cocoadev.com/index.pl?ProjectBuilderTips.

So a typical template looks like this:

/*
 *  main.m
 *  «PROJECTNAME»
 *
 *  Created by «FULLUSERNAME» on «DATE».
 *  Copyright (c) «YEAR» «ORGANIZATIONNAME». All rights reserved.
 *
 */

Now, I know how to define new templates and have done so. However, I want my new template to use my own new tag in it like this:

/*
 *  «ATTRIBUTIONLINE»
 */

... and I want that tag to be definable on a per XCode project basis. Is this possible? I've searched around and can only find the usual stuff about running something on the command line that defines a well-known tag for all projects.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅唱ヾ落雨殇 2024-10-28 09:14:23

使用xCode4,我发现项目模板已经发生了很大的变化。它们似乎更具可编辑性。

附上一个样本。其他人在 ~/Library/Developer/Xcode/Templates/File Templates 中找到了这些模板,

我在这里找到了它们:
/Developer/Library/Xcode/Templates/

新模板示例

With xCode4, I find that the project templates have been substantially changed. They seem to be far more editable.

Attached is a sample. Other people have found these templates in ~/Library/Developer/Xcode/Templates/File Templates

I found them here:
/Developer/Library/Xcode/Templates/

new template example

dawn曙光 2024-10-28 09:14:23

你的问题有点模棱两可。您是否希望某些项目定义标签,而其他项目则不定义标签,或者您希望所有项目在每个项目的基础上包含具有不同值的相同标签?

我不能对此做出明确的说法,但在后一种情况下,“标签可在每个 XCode 项目的基础上定义”只是请求不同的项目创建对话框,在该对话框中可以输入自定义标签的值。前一个问题可以使用不同的项目模板来解决(其中很少有项目模板包含有问题的标签,而其他项目模板则不包含)。

目前,我能想到的唯一解决方案是使用某种命令行实用程序来“预处理”模板,然后根据处理后的项目模板生成项目。类似于 Rails 骨架模板,您可以在其中定义要包含的 Gem,然后将该模板传递给 Rails 命令,该命令又会生成带有预先包含的 Gem 的应用程序骨架。

另外,如果您需要高水平的可定制性 - 将该标签移动到单独的文件模板,然后在创建项目后添加/创建这些文件怎么样?

Your question is a bit ambiguous. Do you want some of your projects to have a tag defined while others not to or do you want all your projects to include same tag with different values on a per project basis?

I can't be categorical about this, but in latter case "tag to be definable on a per XCode project basis" just begs for different project creation dialog where one would be able to enter a value for custom tag. The former problem would be solved with different project templates (where few project templates hold the tag in question, while others not).

For now, only solution I can think of is to have some kind of command line utility that would "preprocess" the template and then would generate project based on processed project template. Something like rails skeleton templates where you can define which gems to include, then pass that template to rails command which in turn generates the app skeleton with preincluded gems.

Also if you require that big level of customizability - how about moving that tag to separate file templates and then adding/creating those files once the project has been created?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文