mac 安装xcode命令行工具

转载:https://segmentfault.com/a/1190000018045211?utm_source=tag-newest

1、启动终端,输入命令:xcode-select --install,然后一路点击安装

2、安装成功后,输入命令:gcc -v 来查看是否成功

若是第一步报错,提示为:xcode-select: error: command line tools are already installed, use "Software Update" to install updates

解决方法:

#删除旧工具

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

#再次安装xcode命令行工具

xcode-select --install

以上命令最好加sudo  有时候也是因为没权限。

原文地址:https://www.cnblogs.com/dearddu/p/12841902.html