Xcode 4:如何自定义文件模板和项目模板? [英] Xcode 4: how to customize File Templates and Project Templates?

查看:22
本文介绍了Xcode 4:如何自定义文件模板和项目模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Xcode 3 中,我们(通过反复试验)确定我们可以将系统模板复制到一个新位置(三个可能的位置,因为 Apple 一直在更改它),并对其进行自定义.

In Xcode 3, we worked out (by trial and error) that we could COPY the system templates to a new location (three possible locations, because Apple kept changing it), and customize them.

注意:在写这个问题时,我发现 StackOverflow 上关于这个主题的大部分答案都是不正确的 :(.Apple 更改了位置,大多数答案都给出了旧位置,这些位置不再有效.

NB: while writing this question, I discovered most of the answers on StackOverflow on this topic are incorrect :(. Apple changed the locations, most answers give the old locations, which don't work any more.

在 Xcode 4.3 中,Apple 再次打破了这一切,现在旧方法无法更改文件模板.通过反复试验,我发现您可以创建新的文件模板(见下文),但无法替换 Apple 现有的文件模板.

At Xcode 4.3, Apple broke it all again, and now FILE TEMPLATES CANNOT BE CHANGED by the old method. From trial and error, I've found that you can create NEW file templates (see below), but the existing ones from Apple cannot be replaced.

我们如何解决这个问题?Apple 的新文件模板简直令人震惊——它们插入了虚假的版权"行,甚至不遵循 Apple 自己的文档标准,更不用说其他任何人的 :(.

How do we fix this? Apple's New File templates are simply appalling - they insert fake "copyright" lines, and they don't even follow Apple's own documentation standard, let alone anyone else's :(.

推荐答案

这只是问题的部分答案,但对于其他人(像我一样)努力找出正确"方法的人来说,这里有一个部分解决方法有效.

This is only a partial answer to the question, but for anyone else struggling (like me) to work out the "correct" way, here's a workaround that partially works.

今天,使用 Xcode 4.5.0,以下工作:

Today, with Xcode 4.5.0, the following works:

自定义文件/项目模板:

Customize file/project templates:

  1. 取消隐藏您的图书馆文件夹(如果您不知道如何使用谷歌,或者从终端执行此操作)
  2. 创建一个文件夹:~/Library/Developer/Xcode/Templates(父文件夹应该已经存在 - Xcode4 自动创建)
  3. 找到您的 Xcode 4 副本,然后右键单击显示包内容"
  4. 在那里导航,直到找到模板"子文件夹
  1. Un-hide your Library folder (google if you don't know how, or else do this from Terminal)
  2. Create a folder: ~/Library/Developer/Xcode/Templates (the parent folder should already exist - Xcode4 auto-creates it)
  3. Find your copy of Xcode 4, and right click "Show Package Contents"
  4. Navigate in there until you find the "Templates" sub folder
  1. 有两个文件夹,一个用于 Mac,另一个用于 iPhone
  2. Mac 位置:[Xcode4.app]/Contents/Developer/Library/Xcode/Templates
  3. iPhone 位置:[Xcode4.app]/Contents/Developer/Platforms/iPhoneOS.Platform/Developer/Library/Xcode/Templates

  • 将内容复制/粘贴到您创建的模板"文件夹中
  • 关键:重命名文件模板"的每个子文件夹,否则苹果将忽略/删除您的模板
  • 注意:在上面的第 2 步中,您还可以声称在以下位置创建该文件夹:

    NB: in step 2 above, you can also ALLEGEDLY create that folder at:

    ~/Library/Application Support/Shared/Xcode/Templates

    ...但这对我来说从来没有用过,并且新安装的 Xcode 4.5 不存在父文件夹,所以我怀疑 Apple 正在逐步淘汰它?(因为他们拒绝记录,我只是猜测)

    ...but that never works for me, and the parent folder doesn't exist with new installs of Xcode 4.5, so I suspect Apple is phasing this out? (since they refuse to document it, I'm just guessing)

    这篇关于Xcode 4:如何自定义文件模板和项目模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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