How to switch xcode on Mac?

How to switch xcode on Mac?

由于学习需要,我在MAC上装了两个版本的xcode,一个是xcode7.3,另一个是xcode8.3. 但在一些情况下我需要切换xcode的版本,于是自己摸索出以下经验。

1. 查看当前版本的xcode

/usr/bin/cc --version

我这里是:

jhmdeiMac:~ jhm$ /usr/bin/cc --version
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

可以看出,我当前版本是xcode7.3.0

2. 切换xcode版本

首先看切换的命令:xcode-select

jhmdeiMac:~ jhm$ xcode-select -h
Usage: xcode-select [options]

Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).

Options:
  -h, --help                  print this help message and exit
  -p, --print-path            print the path of the active developer directory
  -s <path>, --switch <path>  set the path for the active developer directory
  --install                   open a dialog for installation of the command line developer tools
  -v, --version               print the xcode-select version
  -r, --reset                 reset to the default command line tools path

接下来,我们用命令行来切换xcode版本。

sudo xcode-select --switch /Library/Developer/CommandLineTools

当然,要在打命令之前知道自己其他的xcode版本的位置。
用/usr/bin/cc –version来检查是否改变了版本。

jhmdeiMac:~ jhm$ /usr/bin/cc --version
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值