Automatically add copyright license for new files in Xcode

If you are planning to add a copyright license for new files automatically, this is how you do it. Here are the most commonly used macros.

___YEAR___

___FILENAME___

___PACKAGENAME___

___FULLUSERNAME___

___DATE___

Xcode reads the templates from a plist. I am assuming for the sake of this post, you would be using a workspace.

Go to your workspace location. Create a plist at this location. You can create a plist by going to New file and selecting property list.

Redflower.xcworkspace/xcshareddata/IDETemplateMacros.plist

Insert the below text into the plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>FILEHEADER</key>
	<string> *******************************************************************
// REDFLOWER INC CONFIDENTIAL
// ___________________
//
// Copyright ___YEAR___ Redflower
// All Rights Reserved.
//
// NOTICE: All information contained herein is, and remains
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//
// *******************************************************************
</string>
</dict>
</plist>

Now go ahead and save the plist. That’s it. Next time you create a new file, you will automatically see the copyright notice populated.

If you are using a xcode project, you can do the same as below.

Redflower.xcodeproj/project.xcworkspace/xcshareddata/IDETemplateMacros.plist

If you want to create a global copyright, you can do that by going to

~/Library/Developer/Xcode/UserData/

Leave a Reply

Your email address will not be published. Required fields are marked *