1.
Example:
$ cd cocos2d-x
$ ./setup.py
$ source FILE_TO_SAVE_SYSTEM_VARIABLE
$ cocos new MyGame -p com.your_company.mygame -l cpp -d NEW_PROJECTS_DIR
$ cd NEW_PROJECTS_DIR/MyGame
$ cocos run -p mac
xcodebuild -project "/Users/temp/Downloads/cocos2d-x-3.2/projects/MyGame/proj.ios_mac/MyGame.xcodeproj" -configuration Debug -target "MyGame Mac" CONFIGURATION_BUILD_DIR=/Users/temp/Downloads/cocos2d-x-3.2/projects/MyGame/bin/debug/mac
/Users/temp/Downloads/cocos2d-x-3.2/projects/MyGame/bin/debug/mac/MyGame.app/Contents/MacOS/MyGame Mac
https://github.com/chukong/cocos-docs/blob/a1118fdc4095ab0d7d12e46363703f097757d72f/manual/framework/quick/V2/how-to/use-project-mac-and-win/zh.md