How to get Xcode to stop generating copyright headers on your Swift files

I’m tired of having Xcode’s auto-generated copyright headers in my files. They’re totally unnecessary and just add clutter to my code. And I hate clutter.

No copyright header

Here’s how to get rid of the clutter and make your Swift files clean.

(Thanks to Anthony for laying the foundation for this.)

Create a new User File Template

  1. Quit Xcode. Bad things may happen if it’s open while you’re creating a new file template.
  2. Launch Terminal.
  3. mkdir -p ~/Library/Developer/Xcode/Templates/File Templates/User Templates
  4. cd ~/Library/Developer/Xcode/Templates/File Templates/User Templates
  5. cp -r /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/Source/Swift\ File.xctemplate Empty\ Swift\ File.xctemplate

Edit your file template

  1. Open the Empty Swift File.xctemplate/___FILEBASENAME___.swift in your favorite editor.
  2. Delete the copyright header.

Choose your file template when creating a new Swift file

Now it’s safe to launch Xcode. Go ahead and do that now. Now, whenever you create a new Swift file, do the following:

  1. Create a New File.
  2. Choose User Templates on the left.
  3. Choose your Empty Swift File.

Empty Swift File

And enjoy having a little less clutter in your life.

Become a better iOS developer with more of these tips and tricks by joining the mailing list. You’ll establish a foundation in Swift with the 5-Part Guide to Getting Started with Swift, and you’ll continue to get better at iOS with more articles just like this.