Configuring and Using Xcode



If you are a MacOS user using Xcode, make sure you have the latest Xcode installed.

Then, to create a new project, choose the File > New > Project menu option. You'll be presented with a window like this:

01-CommandLineTool


Along the top of the window, make sure that "macOS" is selected and that "Command Line Tool" is highlighted in the "Application" section. Then click "Next"… you will see the following:




02-ProjectSettings


You can fill in whatever name you'd like for the "Product Name". Your "Team" popup may not have anything selected, and that's fine (it's a place to specify your "Team name" if you have an Apple Developer account). You'll need to put something for the "Organizational Identifier". I chose "random.identifier" but any text (without spaces) will do. Finally, make sure that for "Language" you choose "C++". Then click "Next":


03-PlaceToSave

You'll be asked for a place to save the project. I'd suggest making a Folder called something like "Projects" or "Assignments" on your computer where you can put these projects (they'll be created in their own folder inside the directory you specify). When you have navigated to the folder where you'd like the project created, click "Create":


04-ProjectCreated

You will notice that a new project is created that contains a file named "main.cpp".

There are two settings to check to make sure you are ready to run the code. First, select the "Assignment1" project icon the file navigator, like this:


06-SignToRunLocally

Once the project icon is selected, make sure that the "Signing and Capabilities" "tab" is selected and that, in the "Signing (Debug)" section make sure that "Signing Certificate" is set to "Sign to Run Locally". Then, select the "Build Settings" tab:


05-CPP98

After selecting "Build Settings", type the word "Language" in the search field.. Then, find the "C++ Language Dialect" and change it to "C++98". This will ensure that you aren't able to compile anything with C++11 (we *may* need to manually enter C++03 at some point, but for now C++98 will be fine).

Once these settings are "set", click on the triangle near the top left corner of the window to compile and run the application. The output will appear in a console "section" that appears in the main Xcode window:



07-RunApplication

In the window above, you can see "Hello, World!" Is printed out. You'll also see "Program ended with exit code: 0"…. That text is generated by Xcode which is just reporting the value returned by the main function.