How to easily change your file header text in Xcode

The default header generated by Xcode

Have you ever wanted to create your own header text automatically everytime you create your own file? The Xcode help page already explains how to do it. But there is too much information in there for new programmers. So if you are confused, follow this easy tutorial!

What you need

We need two things:

  • A plist file with this name: IDETemplateMacros.plist. We will create this.
  • A location to put the file above.

Creating the plist file

  1. Open Xcode.
  2. Create new file, the shortcut is Command + N.
  3. Scroll down to Resources files, and choose Property List type file.
  4. Click Next, and give the filename IDETemplateMacros.plist.
  5. Save it at the Desktop for now so we can easily find it.

We will move this file to an appropriate place later.

Customizing the text macro

Once you create the plist file, it’s time to modify the plist file and add the macro key for the header text.

  • Open the plist file you have created by double clicking it. I prefer to use Xcode as plist editor.
  • Highlight the Root row and click the + sign.
Add a new key by clicking the + sign.
  • Type FILEHEADER as the key name and make sure the type is String.
Type FILEHEADER as a key name to refer the text placed at the top of every new file.

FILEHEADER is a text macro referring the text placed at the top of every new file in Xcode. The Xcode help has the list of all the macros if you want to know more about other macros.

  • This is the fun part, create your custom header text in your text editor.

I have made my own custom header using TextEdit as shown below, you could write anything and make it as pretty as you want:

The important thing here is the keys that are surrounded by three underscores. PACKAGENAME, FULLUSERNAME, and DATE will be replaced by XCode with its internal values.

Other text macros that could be added: COPYRIGHT, FILEBASENAME, ORGANIZATIONNAME. Don’t forget to surround the macro keys with three underscores before and after the text.

For the full list of text macros, please refer to Xcode help section with keyword “Text macros reference”.

  • After you create your custom header, select All and copy the text.
  • Open the IDETemplateMacros.plist file you’ve made, double click the value row and paste the text there. Press Enter.

The row in Xcode plist editor can only show one line, so it’s fine if you only see the last line of your header.

Paste the custom header from text editor to the value cell.

Congratulations! You have made your own header text and it’s ready to use.

Choosing location to put the plist file

Now, we need to put this file to a place where Xcode will read the macro. Xcode will look for a text macro in the following locations:

  • Project user data:


  • Project shared data:


  • Workspace user data:


  • Workspace shared data:


  • User Xcode data:


You could put the plist file that you made in one of the directories above. If you work on a project you could use the project user or shared data directory. If you work on a workspace you could use the workspace user or shared data. Or, if you really want to use your custom header in all your projects you could put the plist file in the user Xcode data directory.

Below is the example of putting the file in a project user data directory. And, that’s it!

Choosing the project user data directory for the plist file location. (<ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/).

Let’s try

Now that everything is done. Open the project or the workspace where you put the plist file. Or you could open any project if you put it in user Xcode data directory.

Create a new Swift file and admire your work! It is easy isn’t it!!

If you like my post, please like and share. Thank you!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.