If you want to develop applications on your Mac, you have probably heard of Xcode and learned that you would need to install it to have all the required tools and libraries. Thankfully installing Xcode tools is relatively easy to do from Mac Terminal.
By simply running the xcode-select –install command, you can install everything you need to develop software from the command line using Mac Terminal.
My Name is Eric, and I have been a software engineer for over 25 years. To develop applications, you must have the correct tools installed. If you’re going to develop apps from Mac Terminal, I can show you how to get Xcode set up.
Read below if you want to learn how to install Xcode from Mac Terminal. I will also briefly discuss what Xcode is and why you need to install it on your system.
- Quick Install
- What is Xcode?
- Why do I need Xcode?
If you want to develop applications from the command line using Mac Terminal, one of your first steps in setting up your environment will be to install the Xcode command line tools. Follow the steps below to set them up.
Step 1: Start the Terminal application.
Open the Terminal application using your preferred method.
Step 2: Run the xcode-select –install command.
Step 3: Click on Install
In the popup window, click on the install button to install the developer’s tools which let you run the xcode-select commands.
Step 4: Agree to the license agreement
Click on the Agree button to accept the terms of the license agreement.
Step 5: The installer will download and install the software.
The installer will run for about 10 minutes and download and install all the tools, compilers, libraries, and other things you need.
When completed, you will see a message indicating that the software was installed, as shown below.
You should now be ready to create and develop software from the command line using Mac Terminal.
What is Xcode?
Xcode is a set of tools, compilers, and libraries that you can use to develop software for macOS, iOS, iPadOS, tvOS, and watchOS. Xcode supports multiple languages such as C++, C, Objective-C++, Objective-C, Java, Swift, Python, Ruby, and more.
What I have shown above installs the core Xcode tools. This is all you need to develop from the command line in Mac Terminal or another Terminal application on your Mac. With this, you can write code using an editor such as vim, nano, or another command line editor you have available.
Another part of Xcode is the Xcode IDE or integrated Development Environment. This includes a desktop application that lets you edit, compile and test your code. We have not installed this part of Xcode since we are working in Mac Terminal using the command line and don’t need it.
Why do I need Xcode?
You may have been instructed to install Xcode and are unsure why you need it. The Xcode tools are needed to compile the source code you create. For example, if you write code in C++, you will need to compile that code so that the application can be run as an executable file.
The Xcode tools also include code libraries that your applications will link to so that they can perform certain functions, such as displaying messages on the screen or receiving input from a user. The Xcode tools help to compile, link, and create executable files for your applications.
Updating Xcode tools
If you have already installed Xcode command line tools and try to run the xcode-select –install command again, you will see a message similar to the one below.
So you may wonder how to update or ensure you have the latest version. You can do that by using the softwareupdate command. First, you can run it with the -list parameter, as shown below.
This should show you a list of applications that have updates available. If you see Xcode in that list, then you can use the -a parameter to update it.
softwareupdate -a <application name>
Many have reported issues with using the softwareupdate command from the command line to update Xcode. Often this is because you need to update your macOS first. If you see macOS in the list of applications with an available update, then make sure you update that first and then Xcode.
If you are still having issues, it can sometimes be easier to just remove the current version of Xcode tools and then reinstall it. You can do that with the following steps commands.
sudo rm -rf /Library/Developer/CommandLineTools
This will remove the current installation of Xcode tools and begin a new installation as seen in the steps above in the Quick Install section. The new installation will be the latest version available, and you will be good to go.
Below are a few questions frequently asked when discussing the installation of Xcode from Mac Terminal.
Does installing Xcode from Mac Terminal install the desktop IDE?
No, the procedure I have outlined above installs the Xcode command line tools. The IDE, a graphical user interface, must be downloaded and installed from the AppStore. You can find it there by searching for Xcode.
Do I have to pay for Xcode?
No. Both the Xcode command line tools and the Xcode IDE are free development tools provided by Apple. The compilers and libraries are all open-source software created by GNU, so there is never any charge for them.
How do I get the Xcode desktop IDE?
You can download the Xcode desktop IDE from the AppStore. As long as you have an Apple ID, you can find it by searching for Xcode in the AppStore. Once downloaded, you can double-click on the install package, which will be installed and set up on your desktop.
Installing Xcode tools via Mac Terminal is a rather quick and easy process. It only requires opening a Terminal session and running the xcode-select –install command. This will install the Xcode command-line tools, but it does not install the Xcode desktop IDE.
I hope the information I have provided above will help you to install the Xcode command line tools from Mac Terminal. Please let me know if you have any questions or comments. I would love to get your feedback!