xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist

原因:卸载了mac上的xcode,重新安装后发现项目用git提交不了,且有以下报错

xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist
Use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, or use `xcode-select --install` to install the standalone command line developer tools.
See `man xcode-select` for more details.

 

 

依次输入以下指令即可:

以下有注意的点,建议设置 sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer      ,配合flutter对xcode的配置,我用以下加红的位置配置导致我后面因为路径不同flutter对xcode配置失败,我重新卸载才能配置成功

sudo xcode-select -r
 
sudo xcode-select --switch /Library/Developer/CommandLineTools // 不建议用, 用这个 sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer  
 
xcode-select -p

 

最后输入git status得到以下:

 

 

说明:后面我遇到一个问题就是在mac上有两个xcode情况下,安装的xcode导致地址一直是/Library/Developer/CommandLineTools,导致flutter doctor在xcode上一直报错,即使sudo更换地为/Applications/Xcode.app/Contents/Developer  ,步骤如下:

1.删除xcode的所有文件,我这边是直接在官网下的xip文件解析的应用,后面拉到启动台里,但是没法删除应用,我是重新解压了xip文件生成的应用,

2.然后拉到Appclearer程序里,删除xcode下的所有文件,随之启动台的xcode就不能用了,

3.后面点击启动台的xcode根据操作重新安装即可

参考:https://blog.csdn.net/weixin_30721077/article/details/95149418

posted @ 2020-12-13 18:51  lude1994  阅读(2408)  评论(0编辑  收藏  举报