Getting started: Mac

1. Download Xcode from the Apple AppStore.

Step 1

2. Click on the Xcode icon in Launchpad. You may want to consider adding this icon to your Dock for easy access as you will need to go through the following steps for each assignment.

Step 2

3. Select File->New->File from the top menu bar.

Step 3

4. When the next window prompts you to choose a template for your new file, go down below" OS X" and choose "C and C++" then select "C++ Class" then click "Next".

Step 4

5. Select a destination for your file. Typically it is beneficial to create a folder on your desktop or somewhere else very easily accessed to store all of the assignments for this class in one place.Likewise, you may want to name your file with the same name given to the assignment on canvas so that it will be easy to go back and find if you need to reference what you coded.

Step 5

6. After you click "Create" your file should open. You will need to remove the line: "#include "HelloWorld.h" " which Xcode automatically includes. You can also delete the automatically created "HelloWorld.h" file(Move to trash, don't just remove reference). This feature will be useful later on as you continue with programming, but you will not need it for this course.

Step 6

7. Copy and paste the sample code from the Hello World assignment on Canvas, then save the file again. (You should be able to use command-s to re-save the file since you already chose a destination folder.)

Step 7

8. Next open Terminal from inside Launchpad. MacBooks come with this already installed, and it can be found under "Other" - this is another app you will use often and may want to move to the Dock. With this app you will be able to test your code locally rather than having to submit the assignment to find out if it works.

Step 8

9.In Terminal, type "cd" to change the directory, i.e. the folder, that your computer will look in for the file you just saved. In this example, HelloWorld.cpp is saved in a folder called CompilersDemo located on the Desktop. Basically, change the directory to match the path to the folder where your file is located. (Note that folder names must not have spaces in order to be read properly by Terminal.)

Step 9

10.Once in the proper folder, use the command g++ followed by the filename.cpp, in this case: HelloWorld.cpp. This instruction creates an executable file by compiling the code saved in the .cpp file. Next enter the command ./a.out to run the executable file. Your output should show starting on the next line.

Step 10

Note: If you would prefer, you can use TextEdit to create a file rather than opening one in Xcode and having to delete the extra line and file that it creates. Just be sure that you save the file as a .cpp rather than a .txt. Then you should be able to open it with Xcode and use Terminal in the same way. This decision is a matter of your personal preference.