Utilization of Xcode

Creating a new project

1. Launch Xcode. Then, click on Create a new Xcode project.

2. Click on macOS.

3. Select Command Line Tool. Then click on the button Next.

4. Enter the name of the project in the text box Product Name.

5. Enter a name in the text box Organization Identifier.

6. Select C++ from the select box Language.

7. Click on the button Next.

8. Select where you want you project to be stored inside your file system.

9. Uncheck the check-box Create Git repository on my Mac. Then, click on the button Create.

10. The project is now created.

The interface

At the left of the window, we can see the list of the files/folders of the project.

We can open a file of the project into the code editor, in the middle of the window, to edit it, by double-clicking on it.

Here is the file 'main.cpp' opened in the code editor:

We can compile/build the project into a binary executable file (In debug mode) and execute it by clicking on the button with a start symbol:

When we click on that button, the program is run inside Xcode, at the bottom/middle of the window:

The default code simply prints the text "Hello, World!", followed by a new line, to the console and then stops.

Note that if you see, instead of the console, that:

You must click on the following button to display the console:

We can hide/show the left/right sections of the window by clicking on the following buttons:

Adding files to the project

We can add new files to the project by right-clicking on the folder we want to add the file to:

Then, click on New File....

Select the type of the file you want to create (For C/C++, Header file (.h or .hpp) or Source file (.c or .cpp)). Then, click on the button Next.

Finally, enter the name of the file, inside the text box Save As, and click on the button Create.

The file is now created an added to the project:

We can add an already existing file to the project, by simply right-clicking on the folder to add it to, click on 'Add Files to "NameOfTheProjet"...', then select the file from the file system and click on the button Add.

Compile a release executable

By default, Xcode compiles the executable files in debug mode. To compile a release version of the project, click on the menu item Product, then click on Archive.

Then, click on the button Distribute Content.

Click on the button Next.

Finally, select the location, in the file system, where the executable will be saved and click on the button Export.

The content of the folder of the project

Go where you saved your project. You can see the folder of the project.

Inside that folder, you can see the file of the project (Containing the configuration of the project), here named LTCodex.xcodeproj. There is also the main folder of the project, as we saw it from the file list in Xcode, here named LTCodex.

Inside the folder, there are the code files:

We can open the project inside Xcode by double-clicking on the file of the project.