Remove Xcode default header comment
Xcode file template
Every new source file created from Xcode template has top comment similar to this:
It has little useful information, and often incorrect. As file name, project and company changes how can we keep in sync file comments? In Agile environment when we pair on shared computers the author name often set to generic ‘Developer’. We also use version control system that can tell us the date when file was created along with all history of modifications. Let’s just get rid of those boiler plate comments and have extra 7 lines on screen to see source code.
Remove top comments from all sources
To clean up your Xcode project from boiler plate comments use Find and Replace. Within Xcode Find the following regular expression and replace it with empty string:
//\n//.+\n//.+\n//\n//.+\n// Copyright.+$\n//\n\n
This will also get rid empty line after the header and allow the source to be the first line in the files.
Change Xcode templates to have no header comments
Here is a bash script I found thanks to Manav Rathi. You can save it in your home directory, follow the instructions in comments and delete after use. We have to do this on all workstations for every Xcode installation.
Git pre-commit hook
To prevent accidental checkin of sources with boilerplate comments we can create git pre-commit hook using overcommit. See earlier post Xcode project git hooks on how to use overcoomit with Xcode.