C ocos2d for iphone is a free, fast and lightweight framework for building 2d games for iPhone, iPad and iPod Touch. It is built in objective-c and makes incredibly easier the process of making games for iOS compared to use directly OpenGL.
Before we start the tutorial you need to know that you should have a Mac computer. Developing for iOS can only be done at Apple computers. You may also know that you need to join the Apple Developer Program (it’s free) to be able to download the iOS developer tools. It all can be done at http://developer.apple.com/devcenter/ios/program/.
With that said let’s get started.
First you need to download the latest version of Cocos2d at http://www.cocos2d-iphone.org/download. At the moment i’m writing this tutorial the latest version is 0.99.4.
Once downloaded, uncompress the file.
Open up Terminal and type cd.

Then drag the Cocos2d folder that you just uncompressed to the terminal window.

Your terminal command should look like this. If so hit return, else try again.

Now type ./install-templates.sh -u.

Hit return and your installation should start. If you did everything all right your window should look like this.

What we did with this was installing a project template for Xcode. Now when you open Xcode you can select the cocos2d option and start working right away in a cocos2d game without having to add the necessary files every time you start a new game project.
Open Xcode. Click “Create a new Xcode project.

In the left menu, select “cocos2d 0.99.4” at User Templates.

Click Choose and you are ready to start.
To learn more about Cocos2D i recommend you read this book:
In the next iPhone tutorials i’ll be explaining how Cocos2D works and i’ll show you some basic exercises. Stay tuned!.



Fantastic!! I was just searching a good tutorial for game programming and this look quite simple. I wait for next tutorials ^^
(P.S.: forgive my bad english, i’m italian XD)
I’m venezuelan, my english is not perfect either but it seems to be good enough to write this page. hehe.
My mother is italian, she is from genoa!
Please, support me on facebook or twitter:
http://www.facebook.com/pages/OscarVGG/149669261739306
http://www.twitter.com/oscarvgg
Thanks for visiting!
Just by looking at it, you can tell the device has sharper text and its backlight is brighter compared to a Kindle.
Wish more writers were like you. This is awfully fascinating stuff.
This is a great blog, I’m learning a lot. The articles are crisply written and very informative. Thanks much and keep it up!
Three words: iPad. Tomorrow. Awesomeness.
i agree!
The iPad’s 9.7 inch screen, nearly 4 times larger, will allow for much more pleasant extended viewing sessions.
For one reason or another, I can’t see all of this blog, the text keeps hiding? Are you utilizing something crazy?
No….
Found this on Google, great post.
For some reason or another, I can’t see all of this blog, the text keeps hiding? Are you utilizing javascript?
PHP
Lol! I love it!
I’ve the correct version of xcode, but when i go to terminal, hit cd then drag over the folder into terminal, then hit return, it says “No such file or directory” why’s this? can you please help?
Try hitting cd until you see that you are not pointing to any other directory but your computer’s name.
I have the same problem as Alex. I type cd then drag in the folder, hit return… then it sat no such file or directory. I tried it several time, restarted the computer, with different folders. no happenings…:(
It must be some setting in the terminal preferences??? I tried to reset that too.
Hi oscar I keep getting -bash: cd/Users/shoorayner/Downloads/cocos2d-iphone-0.99.4: No such file or directory whatever i do – even with the latest version 5 folder.
Duh! you have to put a space after cd – sorry!
This is exactly why I love twitter, really, can it get much better.
A very helpful I’ll blog this Share
Very nice and helpful information has been given in this article. I like the way you explain the things. Keep posting. Thanks. . .
Incredibly insightful. I like the way you write. Do you provide an RSS feed?
Captivating, I passed this on to a workmate of mine, and he actually bought me lunch because I found this for him, so let me rephrase: Thanks for lunch.
If I linked back to you, would it possible that I use some of your article on my austrian website?
No problem.
Nice!! Great Ifo. Great People. Great Blog. Thank you for all the great sharing that is being done here.
Thank you for reading!
Whoa how are you. I learned your web site on Yahoo and I just wished to say that I think your producing is basically stunning!?! Many thanks all over again for furnishing this articles for absolutely free.
A great resource. Many thanks.
I was very delighted to find this web page.I wished to say thank you to you with regard to this excellent examine!!! I certainly enjoyed each tiny little bit of it and I have you bookmarked to examine out new items you post.
Great, great, great and – did I forget something? Oh, yeah: Great! thanks for sharing that with us. BTW: I’m typing this on my new iphone – cool…
I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work.
This post has good and valuable information, Is nice to see some good articles like this one. Thank you.
Fine website. Great post, have a good day!
Hey thanks so much for the information I really appreciate it
I just have one question: Will there be a problem if I already have an older version of cocos 2d installed? If so have you any advice about how to update it without a problem?
Thanks again,
Barry
I don’t think you’ll have any problem. Anyway, let me know how you did.
Cheers.
Thanks for these Cocos2D install instructions….will now check out your other tutorials. Mucho appreciated.
thnx alot!!
You’re welcome!
Hi,
I installed the newest version of Xcode. Also installed latest version of cocos. When I create a project using Cocos2D, it shows on the toolbar “Base SDK Missing”. The SDK shows up when I make a new project without Cocos.
Any idea why??
Right click the Project icon in the “Group and Files” section (the list on the right). Then select “Get info”.
A window will show up.
In the General tab, at the bottom of the window is an option called “Base SDK for all Configurations:”, select the one that you need (Probably one of the iPhone Simulator SDK’s) and click the button “Rebuild Code sense index”.
That’s all.
Hi,
For some reason that did not work for me. However I found out that holding down the option key then pressing the overview that shows all the SDK’s.
Thanks, Joe…
Thanks, Oscar!
Hello, any idea how to install this in Xcode 4! It is not working!
..please help! I think there has been a change in the directory where xcode is intalled in previous versions!
Thanks for the help, however whenever I run the
$ cd (directory) ./install-templates.sh -u
line nothing happens. I’ve also tried things like
$ cd (directory) sudo ./install-templates.sh -u
but every time nothing happens. Any advice?
i’ve begun to visit this blog a few times now and i have to say that i find it quite great actually. it’ll be nice to read more in the future! :p
I have been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my view, if all webmasters and bloggers made good content as you did, the net will be a lot more useful than ever before.
As an alternative way for those having problem with “drag and drop” the downloaded file to the terminal, I saw the following from the “Cocos2d for iPhone 0.99 Beginner’s Guide” book:
Carry out the following steps for installing the templates:
1. Open the terminal. It is located in Applications | Utilities | Terminal.
2. Assuming that you have uncompressed the folder on your desktop and renamed it as Cocos2d, type the following:
cd desktop/Cocos2d ./install_template.sh
Thanks for the excellent site!
anyone knows why this post ended here, no one said anything after Nov 3rd 2010. thanks!
I’m coming back soon!
Mine isn’t able to install the templates because it says there is no…
rsync: link_stat “/Users/owners/templates/file-templates/CCNode class” failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /SourceCache/rsync/rsync-40/rsync/main.c(992) [sender=2.6.9]
done!
Can’t I just drop the template folder somewhere?
Please help
This didn’t work for me. I am using Xcode 4.0 and the template don’t show up. Anyone know why?
Doesn’t work for me on XCode 4 !!!
“Wow, many thanks a bunch m8″
——————————————————————–
Romance Languages and Literatures
hey dude! nice job, but quick question! I have the newest xcode on my mac, but ur thing wont work when i open xcode? any suggestions?
This seemed to install fine(Cocs2d v0.99.5 & xCode 4.3) but upon opening xCode I have no options for Cocos2D. Will look into it and get back.
Here is the current way to install the templates into Xcode 4
http://www.cocos2d-iphone.org/archives/1412
Oscar,
for some reason after I go through the steps the Cocos2D template doesn’t show in the Xcode 4.0. Any thoughts on where I can start troubleshooting?
Petar
Thanks for creating The Programmer Lifestyle I’m loving the posts. Would you consider a guest article on a web page I assist run? Do you think that you simply could contribute? You may look at our post types at http://www.socal-hockey.com/oldboard/index.php?s=378fd9eae86b2c8bf758fddc7446bd70&showuser=186100 and undoubtedly we could be interested in having you post an article or two on our blog, what do you think? In case you are interested let me know via the contacts page on our web-site.The Programmer Lifestyle is an fascinating name for a blog, keep up the top effort, thanks, from Hedwig Snyder
Wow, what amazing ideas you have. I absolutely love this post.
This is really interesting, You are a very skilled blogger. I have joined your feed and look forward to seeking more of your great article. Also, I’ve shared your website in my social networks!
Thanks!
I enjoy the efforts you will have put in this, thanks for all the good weblog posts.
Hey i followed the sequence to install COCOS2d template.But Cocos2d template doesnt occurs while creating new project in project template menu.
I have XCODE4.
Does anybody using cocos2d with xcode4.Please let me know what to do? Do i need to to something?
Thanks and Regards
Sai
Xcode 4 is awesome in every way, but a headache for Cocos2D… as soon as i learn cocos with xcode 4 i’ll be posting updated information
I am using Xcode 4. My cocoa2d template doesn’t show. Help me
I’m having the same problem! haha, as soon as i figure how to solve it i’ll be posting it
Hi. I already have XCode 4 and cocos2d (0.99.5) installed. Problem is I can’t see the “User templates” (and cocos2d) selection at the new project screen. I’ve tried to reinstall both several times, but it still doesn’t appear. It seems that XCode 4 has different folder structure, doesn’t it?
XCode is in /Developer
cocos is in /Library
I also installed cocos in my user /Users/…./Library too. But I still don’t work.
Please give any help.
Thanks!
XCode 4 seems to have a different procedure for project templates. As soon as i figure it out i’ll be posting it…
Pretty part of content. I simply stumbled upon your blog and in accession capital to claim that I get actually loved account your weblog posts. Any way I’ll be subscribing for your feeds or even I achievement you get admission to consistently fast.
Please go ahead and add more content to the site, I love it!
Wonderful goods from you, man. I have understand your stuff previous to and you are just extremely wonderful. I actually like what you’ve acquired here, really like what you are saying and the way in which you say it. You make it enjoyable and you still care for to keep it sensible. I cant wait to read far more from you. This is really a terrific web site.
With Xcode 4 this method no longer puts the templates in the correct spot.
There is a small guide here that shows how to do it with the newest Xcode:
http://www.cocos2d-iphone.org/archives/1412
Thank you very much
hello any idea on what happen on my installation of cocs2d 0.99.5 i cant see my cocos2d installed and i cant see user templates installed
pleas help me!! i am newbie
Thanxxxxxxx