Xcode format pre-generated code
I have a particular format that I like to put my code in, and every time I create a new UIViewController
(or any other class for that matter), the same auto-generated code from Apple is put in, and I have to spend the 2 minut开发者_运维百科es cleaning it up to be formatted the way I want it before I can even start.
I was wondering if there was a way to set it in Xcode to add in my version of the formatted code, so that I don't have to waste my time re-formatting. Thanks for the help!
You will find all the templates that Xcode uses when you create new files in /Developer/Library/Xcode/Templates. Have a look in their, you should be able to figure out how it all words easily.
Hope it helps.
XCode 4 changes how templates work, and where templates go, so be careful following instructions unless they refer to XCode 4. You can find a few template examples, and the paths to where they go in my XCode4 customization repository:
https://github.com/KiGi/XCode4Customization
The paths where the system templates live is:
/Developer/Platforms/iPhoneOS.platform/Developer/Library/ Xcode/Templates/File Templates
Don't change those, copy and modify in your own library directory:
~/Library/Developer/Xcode/UserData/File Templates
Those paths are also in the "WhereToPlaceFiles" RTF file on github.
Some options:
Learn to be ok with the format
Write code to fix it
Make your own UIViewController template that makes it the way you want
http://blog.carbonfive.com/2009/05/19/custom-xcode-template-for-iphone-development/
you can write your own templates (as others have detailed), and/or just run your sources through a code formatter (uncrustify works well on objc sources).
精彩评论