完全改变整个“标题"在 Xcode 中的所有新文件上 [英] Totally change entire "header" on ALL new files in Xcode

查看:25
本文介绍了完全改变整个“标题"在 Xcode 中的所有新文件上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您在 Xcode 中创建任何文件时,您会得到:**

When you create any file in Xcode you get:**

有没有办法完全改变那个模板?

Is there a way to completely CHANGE that template?

(更改公司名称等微不足道,实际模板如何更改?)

(It's trivial to change the corporate name, etc. How to change the actual template?)

我根本不在乎每次 Xcode 升级时是否必须重做更改.

I do not care, at all, if I have to redo the change each time Xcode is upgraded.

仅供参考,正确的解决方案 - https://stackoverflow.com/a/57510348/294884

FYI Years later, correct solution - https://stackoverflow.com/a/57510348/294884

推荐答案

文件模板创建过程在 Xcode 5 中没有改变,因此您在 Xcode 4 中找到的任何信息也应该在 Xcode 5 中有效.但是要回答您的问题,您必须创建自定义文件模板.复制 Apple 的文件模板之一,这些模板位于 Xcode 的应用程序包中.iOS 文件模板位于 Xcode 5 中的以下位置:

The file template creation process did not change in Xcode 5 so any information you found for Xcode 4 should also work in Xcode 5. But to answer your question, you have to create a custom file template. Duplicate one of Apple's file templates, which are in Xcode's application bundle. The iOS file templates are in the following location in Xcode 5:

Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates

Apple 的其余文件模板位于 Xcode 5 中的以下位置:

The rest of Apple's file templates are in the following location in Xcode 5:

Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates

从 Finder 中选择 Xcode 应用程序,右键单击并选择 Show Package Contents 将带您到应用程序包内的 Contents 目录.

Selecting the Xcode application from the Finder, right-clicking, and choosing Show Package Contents will take you to the Contents directory inside the application bundle.

将文件模板的副本放在以下位置:

Place your copy of the file template in the following location:

/Users/YourUsername/Library/Developer/Xcode/Templates/File Templates/GroupName

GroupName 是新建文件助手左侧的类别名称.您可以创建自己的组名或使用内置名称之一.您的文件模板将出现在 GroupName 类别中.

GroupName is the name of the category on the left side of the New File Assistant. You can create your own group name or use one of the built-in names. Your file template will appear in the GroupName category.

现在是编辑 Apple 文件模板副本的时候了.在 .xctemplate 文件夹中,您应该会看到以下用于 Objective-C 文件模板的文件:

Now it's time to edit your copy of Apple's file template. Inside the .xctemplate folder you should see the following files for Objective-C file templates:

___FILEBASENAME___.h
___FILEBASENAME___.m

FILEBASENAME 前后有三个下划线.在 Xcode 中打开 FILEBASENAME 文件并修改它们以满足您的需要.在您的情况下,这将涉及更改文件顶部的注释.

There are triple underscores before and after FILEBASENAME. Open the FILEBASENAME files in Xcode and modify them to suit your needs. In your case that would involve changing the comments at the top of the file.

创建自定义文件模板是否实用取决于您要复制多少 Apple 的文件模板.复制 Apple 的每个文件模板是不切实际的,但复制 Apple 的 Cocoa Touch 文件模板会更实用.

Whether or not creating custom file templates is practical depends on how many of Apple's file templates you want to duplicate. Duplicating every one of Apple's file templates would be impractical, but duplicating Apple's Cocoa Touch file templates would be more practical.

这篇关于完全改变整个“标题"在 Xcode 中的所有新文件上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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