Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep the header comments up to date in Xcode

Xcode has a habit of putting all kinds of (redundant) information at the top of each code file it creates, containing copyright notices, class names, project names and client names. Like it or not, once you create a new class "A", then refactor it to be called "B", the information is wrong already. The comments will keep saying that this is "A.h" or "A.m". In addition, if you reuse classes from one project in a next, it will also state the wrong project name.

//
//  A.h
//  ProjectName
//
//  Created by Author on 19-06-11.
//  Copyright 2011 CompanyName. All rights reserved.
//

There must be a reason there aren't many people complaining about this. What is your trick to keep the header comments up to date? Is there a tool that auto-corrects it all? Is there a hidden setting?

Cheers, EP.

like image 478
epologee Avatar asked Oct 17 '11 08:10

epologee


People also ask

How do I change created in Xcode?

you can try: System Preferences --> Users & Groups --> choose current User --> unlock -->right tap current User --> Advanced option --> change you full name & above account name to your want, save ,that is ok! I get it from How does Xcode know who the the project was "created by"?


2 Answers

There may be a way to update your comments but it will be tricky.

As far a customizing the template, this is not as bad. it is just a text file located in /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Cocoa Touch/

Don't edit the files here, they will get overwritten when you update, or reinstall xcode. Place your custom templates here, in your home directory.

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

High Order Bit explains further.

like image 172
TMB Avatar answered Oct 11 '22 13:10

TMB


Short Answer: Use SCM Commit Hooks (git example, svn example, cvs example)

Reason: Well, you can be rest assured that XCode will not do it. What XCode can do is attach itself to version control system. Its fairly simple to do using commit hooks that most SCMs support. They fire up before/after the commit/push so that source code is updated. You can even send automated emails when commiting etc.

Since GIT is the most popular one in my opinion these days, see this article.

like image 35
zakishaheen Avatar answered Oct 11 '22 14:10

zakishaheen