Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

Different Ways to Setting Up Environment For C++ Programming in Mac

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Xcode is an IDE developed by Apple themselves to develop apps for macOS and iOS or all other Operating Systems that Apple develops. It also has support for C/C++ built-in. Here, finding a C++ IDE for a macOS system is quite easy. To run a program in C++ in Mac we have to install Xcode or command-line tools for Xcode.


Hence, there are two options to run a C++ program on Mac.

  1. Download and install from Apple Appstore
  2. Download and install by using Command Line Tools and using any preferred IDE or Code Editor for writing C or C++ code.

Way 1: Download and install from Apple Appstore

Note: The macOS version of Visual Studio is not available for C or C++ as we can develop C# but not C/C++.


Step 1: Install Xcode software on the machine on which programs are to be written. So after downloading the Xcode application and later on opening it, you will be greeted by the pop-up as shown below

Step 1.

Step 2: Now click on the link “Create a new Xcode project”.

Step 3: Again, if there is an existing project you will click on “Open a project or file” or “Clone an existing project” if the project is on source control.

Step 4: Click on the macOS tab and then click on the Command-Line app as it the only thing where we can develop apps in C and C++.

Step 2

Step 5: It will now show an interface to give the product or the app a name and the package name as a normal IDE after giving that name there would be a drop-down to select a language. So, instead of swift, you can select C or C++ and click on the Next button.

Step 3.

Step 6: Then it will ask for the location of the project on your machine, and, done!, you can open or create a C or C++ file now.

Way 2: Installing the Xcode Command Line Tools and using any preferred IDE

In this method, we need to use the Terminal as we need to download and install only some part of Xcode and not the entire Xcode. This method is useful if you have limited storage or for some other reason. We will be downloading the 2GB part of Xcode rather than the entire 28GB Xcode as we only need the C and C++ compiler.


Follow the below step to set up the running environment for C++ 

Step 1: Open Terminal and type or copy and paste this command “xcode-select –install” and now Xcode Command Line Tools would be installing you will get an interface like this:

xcode-select --install

Step 2: Now click on Install it will ask for your device password so after entering the password it will install Xcode Command Line Tools. Now we can create a C or C++ file and edit it.

Step 3: Now use VScode or be it else of your choice as it is the best free code and install two extensions for C++. 

Note: The first one is C/C++ official extension and the second one is Code runner

C/C++ extension

Code Runner extension

Now a C /C++ code can be run in VScode.

My Personal Notes arrow_drop_up
Last Updated : 23 Mar, 2021
Like Article
Save Article
Similar Reads