-->

How to Set Up C++ on a Mac


To start C++ coding on a Mac you need to install Apple’s Xcode. This is a free, full featured IDE that’s designed to create native Apple apps. However, it can also be used to create C++ code relatively easily.

XCODE


Apple’s Xcode is primarily designed for users to develop apps for macOS, iOS, tvOS and watchOS applications in Swift or Objective-C, but you can use it for C++ too.

Step 1


Start by opening the App Store on your Mac, Apple Menu > App Store. In the Search box enter Xcode and press Return. There will be many suggestions filling the App Store window but it’s the first option, Xcode, that you need to click on.


How to Set Up C++ on a Mac
How to Set Up C++ on a Mac



Step 2


Take a moment to browse through the app’s information, including the compatibility to ensure you have the correct version of macOS. Xcode requires macOS 10.12.6 or later to install and work.


How to Set Up C++ on a Mac
How to Set Up C++ on a Mac



Step 3


When you’re ready, click on the Get button which then turns into ‘Install App’. Enter your Apple ID and Xcode begins to download and install. It may take some time depending on the speed of your Internet connection.


How to Set Up C++ on a Mac
How to Set Up C++ on a Mac



Step 4


When the installation is complete, click on the Open button to launch Xcode. Click Agree to the licence terms and enter your password to allow Xcode to make changes to the system. When you’ve done that, Xcode begins to install additional components.


How to Set Up C++ on a Mac
How to Set Up C++ on a Mac



Step 5


With everything now installed, including the additional components, Xcode launches, displaying the version number along with three choices and any recent projects that you’ve worked on; although for a fresh install, this shows blank.


How to Set Up C++ on a Mac
How to Set Up C++ on a Mac


Step 6


Start by clicking on Create New Xcode Project; this opens a template window from which to choose the platform you’re developing code for. Click the macOS tab, then the Command Line Tool option and finally, Next to continue.


How to Set Up C++ on a Mac
How to Set Up C++ on a Mac



Step 7


Fill in the various fields but ensure that the Language option at the bottom is set to C++. Simply choose it from the drop-down list. When you’ve filled in the fields, and made sure that C++ is the chosen language, click on the Next button to continue.


How to Set Up C++ on a Mac
How to Set Up C++ on a Mac



Step 8


The next step asks where to create a Git Repository for all your future code. Choose a location on your Mac, or a network location, and click the Create button. When you’ve done all that, you can start to code. The left-hand pane details the files used in the C++ program you’re coding. Click on the main.cpp file in the list.


How to Set Up C++ on a Mac
How to Set Up C++ on a Mac


Step 9


You can see that Xcode has automatically completed a basic Hello World program for you. The differences here are that the int main () function now contains multiple functions and the layout is slightly different. This is just Xcode utilising the content that’s available to your Mac.


How to Set Up C++ on a Mac
How to Set Up C++ on a Mac



Step 10


When you want to run the code, click on Product > Run. You may be asked to enable Developer Mode on the Mac; this is to authorise Xcode to perform functions without needing your password every session. When the program executes, the output is displayed at the bottom of the Xcode window.


How to Set Up C++ on a Mac
How to Set Up C++ on a Mac


0 Response to "How to Set Up C++ on a Mac"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel