1. You Download COCOS2D latest version from
“http://www.cocos2d-iphone.org/download” this .link
2. keep it on your desktop
3. open the terminal and type “cd”
4. drag your latest version of -> COCOS2D package folder in to your terminal window.
5. type sudo and open the COCOS2D package folder and drag the “install-templates.sh” file into your terminal windows and press enter.
6. put your system password to install templates.
now open your xcode. you will get the COCOS2D in xcode