This tutorial will demonstrate how to create and run your first C++ application in Mac OSX by using Xcode.

1. Launch Xcode.

XCode C++ Example

2. Choose “Select a new Xcode project” from the Xcode window.

XCode C++ Example

3. Select “Command tool” from the project template window as we are going to create a simple c++ command console program.

XCode C++ Example

4. You will need to fill in some information about the project in the next wizard. I called this product name “HelloWorld”. Make sure that you enter the company identifier information. Lastly, make sure that you are choosing C++ in the project type.

XCode C++ Example

5. You will need to specify where to keep you project. I create a sample folder for myself and called it cpp.

XCode C++ Example

6. Click create to finish and launch the Xcode IDE now.

7. Click the main.cpp file on the left hand side.

C++ Xcode Example

8. You should be able to edit the file now in the Xcode editor. Add the following line of code after the “Hello, World”:

1
std::cout << "Running my first cpp program using Xcode!" << std::endl;

C++ Xcode Example

10. To build and run the program, press cmd+B or select Product->Run from the Xcode menu.

11. Your project should compile success now and notice that the output window should show the following result:

C++ Xcode Example