Playing with Xcode: Modifying the comment template generated by the system

Playing with Xcode: Modifying the comment template generated by the system

When using Xcode to create a project or a new class, there will be some comments generated by Xcode at the top.

  1. //  
  2. // MySingletonClass.h  
  3. // Singleton mode  
  4. //  
  5. // Created by Hong Feng on 15/8/12.  
  6. // Copyright (c) 2015 Hongfeng. All rights reserved.  
  7. //  

For example, the above paragraph, but sometimes we want to add some content to this part of the comment, such as our own blog address, github address, company information, etc.

Especially when you want to open source some tools or write some frameworks yourself.
At this time, we can't modify the files one by one, which is too cumbersome. In fact, these Xcode templates are written in a folder.
We just need to go in and modify the corresponding files to solve the problem once and for all.
Folder location, application - find xcode - right click to show package contents Xcode ▸ Contents ▸ Developer ▸ Platforms ▸ iPhoneOS.platform ▸ Developer ▸ Library ▸ Xcode ▸ Templates

If you can’t find this folder, you can search in Contents: Cocoa Touch Class.xctemplate

There are two folders in the Templates folder

Among them, File Templates is what we want to modify, and Project Templates is some descriptions we see when we create a new project, which are fixed codes automatically generated. I will talk about this part later.

The above is the selection interface that pops up when we create a new class, and the following is the content in File Templates. Is it clear at a glance? Let's go to Source and take a look

Snip20150812_1.png

There are many folders in the Cocoa Touch Class.xctemplate under the Source folder (as shown below). As the name suggests, I believe everyone should know what it means.

Snip20150812_5.png
I will take modifying the files in NSObjectObjective-C as an example

The source file is

  1. //  
  2. // ___FILENAME___  
  3. // ___PROJECTNAME___  
  4. //  
  5. // Created by ___FULLUSERNAME___ on ___DATE___.  
  6. //___COPYRIGHT___  
  7. //  
  8. # import   "___FILEBASENAME___.h"  
  9. @implementation ___FILEBASENAMEASIDENTIFIER___
  10. @end  

The comments above are where we want to modify. How to modify it depends on your own preferences.

___xxx___These three underscores are equivalent to the booth symbol,

___FILENAME___ means to get the file name according to the file ___DATE___ means to get the current date>

Here are the changes I made:

Snip20150812_9.png

Because _ has a special meaning in Markdown syntax, this paragraph is too painful to edit, so I just took a screenshot in the end.

After the modification is completed, use Xcode to create a new class that inherits NSObject. The default generated comment template is as follows

Snip20150812_7.png

I believe everyone should know what to do later~

<<:  MIUI head Hong Feng tells you why MIUI7 is like this

>>:  New features of iOS 9 SDK that developers need to know

Recommend

Content operation: How to build a complete UGC content ecosystem?

What steps are needed to build a complete UGC com...

Apple: Court's request to unlock iPhone is unconstitutional and beyond authority

Apple fought back in court on Thursday against a ...

If I am nearsighted, do I still have a chance to become an astronaut?

Becoming a cool astronaut is a dream that almost ...

These "grapes" are free, but they can cost you your life!

In nature, there are many kinds of grapes that ar...

Wolf Shuai's A-share Devil's Dictionary - Stock Market Secrets

Lang Shuai's A-share Devil's Dictionary -...

Using deep neural networks to solve the problem of NER named entity recognition

This article is organized as follows: What is Nam...

Between ofo and Mobike, which one has the better operational strategy?

In December 1922, the last emperor Puyi married W...