xcode project templates - cocos2d v2.x

I do File->New->Project far more than the average developer, and this is because of the fact that I am still spending my days studying, and very often practicing with various Cocoa Touch APIs in new ways. I also spend my time, as mentioned in this last post, playing around with cocos2d and getting to grips with the various tricks to make an optimised and fun game.

Unfortunately, anybody who sets up a new cocos2d project at least a few times knows that the standard template sucks. There are errors with the autorotation implementation, warnings with the use of deprecated methods in the cocos2d library, and it's generally quite messy. After sorting it out so many times, and even saving my own versions of each of the basic files generated by the project, I decided to try making a template.

The cocos2d project templates (in Mountain Lion) can be found at the location: 
Here there should be a folder called cocos2d v2.x which includes just a load of other folders representing project templates as well as the base templates shared by many of the others. There was also a folder 'File Templates' there, but that's just full of the templates generated when you go to File->New->File… and use the cocos2d v2.x files to inherit from (like CCNode).

I simply duplicated the basic folder cocos2d iOS.xctemplate, renamed it with my own title (I chose 'Custom cocos2d iOS.xctemplate') and then began editing it. First of all you need to change the identifier in TemplateInfo.plist, and then you can open up the AppDelegate files, and the HelloWorld files and change them. If you add any new files, you'll need to add them to the TemplateInfo.plist in both the Nodes and Definitions keys. In the Definitions keys each item is an array where you can also define which folder it should be automatically placed in.

A lot of the other details are found in the base_ios templates and the other base templates. For example I changed the automatic iOS Version from 4.0 to 6.0 here. I'll include my custom template just in case, and all that you guys will need to do is drag it into the folder I mentioned at the top of this article. Unfortunately I don't know how to automatically enable ARC, so that still needs to be done when the project is first opened. You will need to fix the errors in the cocos2d library yourself as well, because those files are in another base folder.

Here's my project and I really hope that I've helped you in some small way. Please contact me at Twitter (infinityjames) or App.net (andbeyond) if you have any questions or comments.