قالب وردپرس درنا توس
Home / IOS Development / # 314: Install and Replace Xcode Versions from the Command Line 🛠 – Little Bites of Cocoa

# 314: Install and Replace Xcode Versions from the Command Line 🛠 – Little Bites of Cocoa



Issue

Topics

This time of year it is common to have more versions of Xcode installed.

Today, we'll learn to tell our system what version of Xcode tools to use when working with Xcode from the command line . But first, we will check out a useful tool for actually install Xcode from command line .

Let's go diving.

The first tool we view can be used to install Xcode versions directly from the command line . There is an option to use the Mac App Store (or manage downloads only manually).

It is called xcode-install and it is located on Github here. [1

9659000] We can install it with:

  save install xcode-install  `

When done, we can view the versions of Xcode available for installation from the command line ] like this:

  xcversion list

As at the time of this writing, you will print:

  8
8.1
8.2
8.2.1 (installed)
8.3 (installed)
8.3.1
8.3.2
8.3.3 (installed)
9 beta 4

By default, xcode-install only writes the last few main versions. Pageote: For fun and nostalgia, try running xcversion list --all to print all available versions of Xcode goes back to 4.3 for OS X Lion 😱). [19659000]] We are able to install a version like this:

  xcversion install  "9 beta 4" 

We are asked for our Apple Developer ID that will be stored in our ] Keychain and then the version will be downloaded, installed and moved in place, all without leaving command line .

Neat!

More information about xcode-install can be found here at Github.

Next, we need a way to switch to the new version we have just installed.

The tool to work with is already installed on ou r Mac and is called xcode-select .

It's a simple, one-time utility that essentially controls which drive on the drive that drives when driving xcrun ] xcodebuild etc. from our command line .

Let's first check which version of Xcode we are currently using:

  xcode -select - write path

Which (by default) will print:

  /Applications/Xcode.app/Contents/Developer

(Note: This is what is written for versions of Xcode installed from the App Store ).

Next, we can view all of versions of Xcode we have installed.

Here we will handle for Xcode inside of our / Applications directory:

  ls / Programs | grep Xcode

Which (for example) will print:

  Xcode-7.3.1.app
Xcode-8.2.1.app
Xcode-8.app
Xcode-9-beta-4.app
Xcode.app

All we need to do to override default Xcode The track is matched to one of these Xcode catalogs with - switch flag:

  sudo xcode-select - switch /applications/xcode-9-beta-4.app

We need sudo since this xcode-select works at system level.

Also note how we have omitted xcode xcodebuild xcode-select will deduce it for us).

Now when we drive xcrun xcodebuild etc. from our command line we use Xcode 9 Beta version of each tool.

Nice.


Source link