Swift Tricks

My own, mostly internal blog of Swift tips and tricks

Change default copyright file header in Xcode projects

Xcode’s default copyright header sucks. Fortunately you can change it on a per project (workspace) level or systemwide…both for a single user and also for all users. All you need is an appropriately formatted plist file in the right location.

(This doc reflects Xcode 9+.)

Where to put the plist?

This depends on which level you want affected:

  • 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

What to put in the file?

The file should contain the text and can also contain some placeholder variables surrounded by three underscores such as ___VARIABLE__. Here is a full example:

<?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">
// (c) Company Name GmbH (___YEAR___)
// This computer program is the sole property of Company
// Name GmbH (http://www.company.com) and is protected
// under the German Copyright Act (paragraph 69a UrhG).
// All rights are reserved. Making copies, duplicating,
// modifying, using or distributing this computer program
// in any form, without prior written consent of Company
// Name GmbH, is prohibited.
// Violation of copyright is punishable under the German
// Copyright Act (paragraph 106 UrhG).
// Removing this copyright statement is also a violation.