13

I've found a few answers on how to change your company name, but is there any way to change the entire copyright template in Xcode?

For example:

Change :

(c) 2012 MyCoolCompany

to :

(c) 2012 MyCoolCompany, unauthorized reproduction is prohibited, contact bla-bla-bla@example.com for details, etc.
user
  • 86,916
  • 18
  • 197
  • 190
Chris
  • 1,037
  • 15
  • 26

1 Answers1

20

Go to :

/Developer/Library/Xcode/Templates/File Templates

or if you're using the newer self contained Xcode.app,

/Applications/Xcode.app/Contents/Developer/Library/Xcode/Tem‌​plates/File Templates

To avoid the templates from being clobbered by Xcode updates, make a copy of the template that you want to edit and move it to your home library folder–

~/Library/Application Support/Developer/Shared/Xcode/File Templates

If - let's say - it's the Objective-C class template you want to change then, go to the following subdirectory :

/Cocoa/Objective-C class.xctemplate

Open :

NSObject/___FILEBASENAME___.h
NSObject/___FILEBASENAME___.m

And edit them.


Hint : You'll have to tweak as many template files as you need (e.g. if you need your copyright header to be valid for NSDocument subclasses, then make sure you edit those files too... ;-))


An example (of what my ___FILEBASENAME___ files look like) :

/******************************************************
 | ___PROJECTNAME___
 |******************************************************
 | File : ___FILENAME___
 | 
 | Created on ___DATE___
 | By Ioannis Zafeiropoulos (a.k.a. Dr.Kameleon)
 |*********************************************************************
 | Copyright (c) ___YEAR___ InSili.co.uk. All rights reserved.
 |*********************************************************************/
Harsh
  • 389
  • 2
  • 18
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
  • @Chris You're welcome, my friend! - I myself have had lots of trouble with that quite a while ago, and it's definitely one of those features that are NOT so well documented by Apple (if at all) (Btw, just edited a bit, so that it's a bit more... explanatory) – Dr.Kameleon Apr 10 '12 at 22:15
  • 9
    With iOS 5.2 SDK and the self-contained Xcode.app, that location would translate to **`/Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File Templates`** – WrightsCS Apr 10 '12 at 22:24
  • @WrightsCS The funny thing is that I updated to 4.2 on my Snow Leopard-powered iMac just yesterday, and JUST realised that my custom template files are gone. What's even crazier is that I'm editing the files at the above location (the one I posted) and nothing seems to change when I create e.g. a new `NSObject` subclass. What could be going wrong? (I don't think there are located anywhere else, as I've searched for them...) – Dr.Kameleon Apr 10 '12 at 22:49
  • @Dr.Kameleon try doing a search for **`// ___PROJECTNAME___`** to make sure you edited all of the available templates. – WrightsCS Apr 10 '12 at 22:53
  • 1
    You should use your home library folder for custom templates, to avoid them being clobbered by updates -- ~/Library/Application Support/Developer/Shared/Xcode/File Templates – jscs Apr 11 '12 at 01:19