How to Install Cocos2d 0.8 Project Template
Step 1: Download Cocos2d 0.8 Beta project template from here. This template works well for 0.8 beta, rc, and final version.
Step 2: Unzip the downloaded file in Step 1. Move the the folder to project templates folder. On my desktop, this folder’s location is /Developer/Platforms/iphoneos.platform/developer/library/xcode/project templates/application.
Step 3: Download Cocos2d Library from here. Untar the file, then move the folder to /Developer/Library.
Step 4: Under xcode – Preferences – Source Trees, add a source record. You can set the setting name with COCOS2D_SRC. The path is the location of Cocos2d Library, which is /Developer/Library/cocos2d-iphone-0.8/
Step 5: Now, you can create a Cocos2d project in xcode. The Dependency and Linked Library of cocos2d and Chipmunk have been added to the project by default.
Step 6: If you want to use other libraries (e.g., Box2d, etc) integrated in cocos2d, please follow the steps below.
Step 7: Add Direct Dependency. After a new project is created, right click the target and select Get Info. Under General, click the ‘+’ button of Direct Dependencies. You will see a list of target dependencies, just add the dependency you want (e.g., box2d). This step can guarantee the static library always exists (if not, the compiler will build one).
Step 8: Build the project. The dependency you added in Step 7 was built up in this step.
Step 9: Add the Linked Static Library to the project. built up in Step 8. Right click the target and select Get Info again. Under General, click the ‘+’ button of Linked Libraries. In the popped-up library list, you can’t find the library built up in Step 8. You need to click “Add Other” button. Then you need to find the library yourself. The library just built up is under the folder /Developer/Library/cocos2d-iphone-0.8/build/Debug-iphonesimulator. Select the library you just built up (e.g., libbox2d.a). Now, the library has been added to the project. Click cocos2d-iphone.xcodeproj on the left side, find the target (i.e., Static Library) you want to add from the file list on the right hand side. Just simply tick the target (e.g., libbox2d.a) as shown below:

All done!
———————–
Update: In the future, if a newer version of Cocos2d is released, what you need to do is just to replace the old Cocos2d library with the new one. You don’t need to update the template. It’s very easy, isn’t it?

Thanks a million. This is very useful. Just tried it with 0.8 and it works like a charm.
Hi,
Thanks for this template.
Before, i have created template for lower version and i removed this folder from /Developer/Platforms/iphoneos.platform/developer/library/xcode/project templates/application even though i am getting this template.
I followed your way to create template for version 8 but i am getting old one and i am not able to get new template.
Where i am wrong?.
Thanks,
to Crazy Dev,
This post is actually presenting how to use the template mentioned in Step one. The template you downloaded in step one works well for all 0.8 versions, even though the downloading page said it is Cocos2d 0.8 Beta project template.
If you only use Cocos2d and Chipmunk, you can ignore the step 6 to 9 because the dependency and linked library of Cocos2d and chipmunk have been set by default in the template you downloaded in Step 1. This is reasonable because Cocos2d and Chipmunk are mostly used. You only need to add other libraries when necessary. This can save a lot of compiling time.
The step 6 to 9 is telling you how to add other libraries to a new project which is created with the template you have downloaded in Step 1.
hey
first of all thanx for template
i hav done all these steps but after build it i get the following error:
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.0 failed with exit code 1
what should i do..
thanx in advance
Hi Gaurav,
The information you provided is too limited, but I think you haven’t
added static libraries properly. Could you please provide more information
or send me the project files, I can have a look.
My email: jiangli001 [AT] gmail.com
Hey I am very thankful for ur reply
hv just mailed u my project files..
Thanks again
I’ve done all the steps up to 5 but when I try to build it says that it cant find cocos2d.h
I have cocos2d-iphone.xcodeproj in my project and it has the library libcocos2d.a
Cocos2d.h is in that library correct?
What am I doing wrong?
@Markos
Hi, i think there is a problem with the “user header search paths”. Please double click your project
name on the sidebar to open project setting dialog. You should check if the User Header Search Paths include your Cocos2d library path.
The path is fine I think. It points to $(COCOS2D_SRC) which is set as “/Developer/Library/cocos2d-iphone-0.8/” in the source trees of the preferences of xcode. So the path says “/Developer/Library/cocos2d-iphone-0.8//**”.
Is there anything i am doing wrong?
@Markos
Yes, that’s correct if you put your library’s folder is /Developer/Library/cocos2d-iphone-0.8/. It’s a little strange. I tried it again, and it works fine on my desktop. You can send me your code if you want, I will have a look tomorrow. My email: jiangli001 [AT] gmail.com
I had trouble as well Markos.
Renaming the directory from “/Developer/Library/cocos2d-iphone-0.8″ to “/Developer/Library/cocos2d” fixed that problem using the 0.8 final.
I’ve got a problem now that libbox2d.a isn’t compiling though, and the compiler is saying -lbox2d is missing…
I definitely have box2d under the cocos2d, and it compiles but libbox2d.a is in the red…
Hi
I’m having the same problem – i think.
ive done exactly what’s asked above and I get 91 errors when linking.
cant find cocos2d.h libcocos2d libraries.a is red
also cocos2d sources folder in project has all its files as red
No worries – i downloaded the beta v0.8.1 and rand the template script. all is fine now
Thank you very much for your aticle!!!:)
It just won’t work…
I did everything as written ere, and get 104 errors. The sources for Cocos2D aren’t being found (Files show in red). If I manually import them (“Add Existing Files”) I get 78 errors of the kind:
“…gcc-4.2 failed with exit code 1″
Libraries, Frameworks, User Defined Headers… Why does it have to be such a pain in the a**?
I was happy with the bundled v0.7 until I wanted to add Denshion…
*I’m using 10.6 with the latest SDK (3.1.3, Xcode 3.2.1).
*I used the library version from step 3 in step 1 as well, because github was offline…
Now I got github working but still… I’ll try 0.8.1 as NigelH said above…
So in the end I run the install_template.sh bundled in 0.8.2 and it worked.
I had to cd / in the console though, I tried double clicking the .sh file before and it wouldn’t work…
I’ve been trying to install cocos2d with xcode but I coudn’t. Today it really helped me, at last I’ve successfully installed. Thank you very much.
@Kamol
Hi Kamol,
Have you tried the installation script in the latest version of cocos2d iPhone?
I think that would be easier.
http://www.cocos2d-iphone.org/wiki/doku.php/resources:templates