更新 XCode 项目模板详细信息

发布于 2024-12-12 16:28:17 字数 250 浏览 0 评论 0原文

以前所有文件头都显示如下。

//  Created by ABC_User_Name on 10/31/11.

我已将用户名从 ABC_User_Name 修改为 XYZ_User_Name

现在,即使在注销后,再次登录,我在所有项目模板中发现相同的标题。如何使用当前用户名更新这些模板?

我需要手动修改所有这些吗?

Previously all file headers were being displayed as follows.

//  Created by ABC_User_Name on 10/31/11.

I have modified user name from ABC_User_Name to XYZ_User_Name.

Now, even after logging out & logging in again, I am finding the same headers in all project templates. How to update those templates with current user-name ?

Do I need to modify manually all of them ?

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

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

发布评论

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

评论(2

怀里藏娇 2024-12-19 16:28:17

原始模板使用此标题:

//  Created by ___FULLUSERNAME___.
//  Copyright ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.

带有双下划线的单词是占位符引用。据我所知,有 18 个,您可以在模板定义中添加更多。可以使用选项变量进一步修改这些选项。您在上面看到的内容是:

  • ___FULLUSERNAME___ 当前用户的完整用户名(姓名 + 姓氏)。
  • __YEAR__ 当前年份。
  • ___ORGANIZATIONNAME___ 地址簿中显示的组织名称。您可以为每个项目更改它,选择“项目”节点并设置“组织”字段。

项目创建后,标题将变为纯文本并且永远不会更新。


对于未来的项目,我建议您复制模板并在那里进行更改。否则,您可能会搞砸原始模板或让 Xcode 覆盖您的更改。

原件位于:

/Developer/Library/Xcode/Templates/
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates 

我在以下位置制作了副本:

mkdir -p ~/Library/Developer/Xcode/Templates/File\ Templates/Jano
mkdir -p ~/Library/Developer/Xcode/Templates/Project\ Templates/Jano

其中“Jano”是我的用户,它将在新项目选择屏幕中显示为模板类别。

User templates

然后,您可以逐个文件手动编辑标头,或者使用 sed 从 bash 编辑标头。

The original templates use this header:

//  Created by ___FULLUSERNAME___.
//  Copyright ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved.

The words with the double underscore are placeholder references. There are 18 that I know of, and you can add more in your template definition. These options can be further modified using option variables. The ones you see above are:

  • ___FULLUSERNAME___ Full user name of the current user (name + surname).
  • __YEAR__ Current year.
  • ___ORGANIZATIONNAME___ The name of your organization as seen on your address book. You can change it for each project selecting the Project node and setting the Organization field.

Once the project is created, the header becomes plain text and is never updated.


For future projects I suggest you duplicate the templates and do the changes there. Otherwise you risk screwing up the original templates or having Xcode overwrite your changes.

The originals are at:

/Developer/Library/Xcode/Templates/
/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates 

And I made a copy at:

mkdir -p ~/Library/Developer/Xcode/Templates/File\ Templates/Jano
mkdir -p ~/Library/Developer/Xcode/Templates/Project\ Templates/Jano

where "Jano" is my user and it will show as a template category in the new project selection screen.

User templates

Then you edit the header manually file by file, or from bash using sed.

疏忽 2024-12-19 16:28:17

Xcode 4 将其存储在每个项目的基础上。

如果您在项目导航器 (Cmd-1) 中选择项目并打开文件检查器 (Cmd-Opt-1),您将在“项目文档”下看到“组织”字段。

Xcode 4 stores this on a per-project basis.

If you select the project in the Project Navigator (Cmd-1) and open the File Inspector (Cmd-Opt-1), you'll see a field for "Organization" under "Project Document".

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