How to Create Your Own Cocos2d Project Template

In this article, I will present how to create your own Cocos2d project template. The version of Cocos2d is 0.8. The approach used in this article can also be applied when creating the project template using other static libraries.

Step 1: Download the Cocos2d library from here. Untar the file, then move the folder cocos2d-iphone-0.8 to/Developer/Library. For convenience in following steps, we first add a source entry in xcode Preferences as follows:

Step 2: Make a copy of Window-Based Application Template and name it with “My Cocos2d Application“. On my desktop, Window-Based Application Template locates in folder/Developer/Platforms/iphoneos.platform/developer/library/xcode/project templates/application. Place the copied template My  Cocos2d Application in the same folder.

Step 3: Get into the folder My Cocos2d Application, and open the file ___PROJECTNAME___.xcodeproj. DeleteMainWindow.xib from the Resources group because Cocos2d project doesn’t need this nib file.

Step 4: Edit Info.plist file. Remove entry “Main nib file base name”. Add a UIStatusBarHidden entry to hide status bar.

Step 5: Add some required libraries. Double Click the target “___PROJECTNAME___” to open Target Info dialog. Click “+” button under  Linked Libraries. Add the libraries shown below:

Step 6: Go to the folder of Cocos2d library /Developer/Library/cocos2d-iphone-0.8,  drag and drop the filecocos2d-iphone.xcodeproj under “___PROJECTNAME___” on the sidebar. Please don’t check “Copy items into destination group’s fold (if needed)”. Select “Reletive to COCOS2D_SRC” as the Reference Type. The screen shot is shown below:

Then what we need to do is ticking the required Cocos2d static libraries (libChipmunk.a, libcocos2d.a, libbox2d.a) as shown below:

Step 7: Add Dependencies. Double click the target “___PROJECTNAME___” to open Target Info dialog. Click “+” button under Direct Dependencies. Add box2d, Chipmunk, cocos2d to the dependency list.

Step 8: Add “User Header Search Paths“. Double click “___PROJECTNAME___” to open project Info dialog. Under Build Tab, double click “User Header Search Paths” and you will see the following dialog. Add the same path shown in the picture.

Step 9: Updating the codes. The codes actually depend on your requirements. You can download an example of files main.m and ___PROJECTNAMEASIDENTIFIER___AppDelegate.m from hereNote: updating the main function in main.m is necessary.

int main(int argc, char *argv[]) {
	NSAutoreleasePool *pool = [NSAutoreleasePool new];
	int retVal = UIApplicationMain(argc, argv, nil, @"___PROJECTNAMEASIDENTIFIER___AppDelegate");
	[pool release];
	return retVal;

Step 10: Add fps_images.png to Resources.

All done! Now you can create a new Cocos2d project with the project template you just created.

Posted on 29th July 2009 in iPhone Development  •  No comments yet

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>