Changing the default header comment license in Xcode

First try changing your Name and Organization your contact card in Address Book.

If that doesn't work, open System Preferences > Users & Groups > Right click on your user (System Preferences must already be unlocked) > Advanced Options... > Change the name in the Full Name text box.

To change the organization name in Xcode click on the project file so it is selected (left sidebar of Xcode in the Project navigator) > In the File Inspector (right sidebar of Xcode) change the Organization text box.

Organization text box


With Xcode 9 there is a built-in option which you can find in the details below.

  1. Create a property list file named IDETemplateMacros.plist
  2. Add a FILEHEADER value to the Root and set its string value with your copyright text like Copyright © 2017 ...
  3. Copy the file to one of the following locations
    • For a single project and user <ProjectName>.xcodeproj/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
    • For all team members in a single project <ProjectName>.xcodeproj/xcshareddata/IDETemplateMacros.plist
    • For all projects in a workspace for a single user <WorkspaceName>.xcworkspace/xcuserdata/[username].xcuserdatad/IDETemplateMacros.plist
    • For all projects in a workspace for all team members <WorkspaceName>.xcworkspace/xcshareddata/IDETemplateMacros.plist
    • For everything you work on, regardless of project ~/Library/Developer/Xcode/UserData/IDETemplateMacros.plist
  4. Create a new file - you should see the new copyright header

Sample IDETemplateMacros.plist for copy and paste:

<?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>
//  Created by Your Name on 29.12.17.
//  Copyright © 2017 Your Company. All rights reserved.
//  </string>
</dict>
</plist>

This blog post has some good steps for modifying file templates in Xcode 4.3:

http://error-success.piku.org.uk/2012/04/27/how-to-make-xcode-4-3-2-templates/

The /Developer folder no longer exists, so you copy the templates from within the Xcode.app bundle located in /Applications:

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

And place your modified copy here, as before:

~/Library/Developer/Xcode/Templates/File\ Templates/

UPDATE: I decided to write a script that would extract the built in Xcode templates and replace the headers. Source and instructions can be found at the following url:

https://github.com/royclarkson/xcode-templates

Tags:

Xcode