Step by step installing Cocos2d 0.99.4 and solve error problem while installing it.
1- Download Cocos2d for iPhone.
2- Click Spotlight
3- Search & Run Terminal
4- In terminal type cd
5- Hit space once.
6- Drag Cocos2d folder to the terminal

7- Hit Enter.

8- Browse to Cocos2d folder and locate file “install-templates.sh”.
9- Drag file install-templates.sh to the terminal and hit Enter.
10- You may get this Error
Error: This script must be run as root in order to copy templates to /Library/Application Support/Developer/Shared/Xcode
Try running it with ‘sudo’, or with ‘-u’ to install it only you:
sudo /Users/abdullah/Documents/downloaded/cocos2d-iphone-0.99.4/install-templates.sh
or:
/Users/abdullah/Documents/downloaded/cocos2d-iphone-0.99.4/install-templates.sh -u
Error: This script must be run as root in order to copy templates to /Library/Application Support/Developer/Shared/Xcode
Try running it with ‘sudo’, or with ‘-u’ to install it only you: sudo /Users/abdullah/Documents/downloaded/cocos2d-iphone-0.99.4/install-templates.shor: /Users/abdullah/Documents/downloaded/cocos2d-iphone-0.99.4/install-templates.sh -u
11- Copy and paste this line sudo /Users/abdullah/Documents/downloaded/cocos2d-iphone-0.99.4/install-templates.sh
12- hit Enter
13- Enter your Admin password
14- installation Done and the template installed on Xcode.
Note: if you dont have Admin password then create one, to do so:
Step by Step Create Admin Password on MAC
1- click Apple
2- System prefrences
3- Acounts
4- Change Password