First take a look here on cocos2d website Cocos2d
and download the source at this moment cocos2d v3 RC4
If you downloaded the installer, simply run it. It will automatically install everything you need. If you have downloaded the zip, and want to install Cocos2D manually, unzip to any folder, open terminal, and change to the unzipped folder. Then run ./install.sh -f
Type ./install.sh -h to see available options.
If Cocos2D V3 was installed successfully, you will now have the option to create a Cocos2D V3 project under Create New Xcode Project in Xcode.