在运行npm安装时看到以下错误,需要node-gyp…但可以被任何需要xcode-select的东西触发。

xcodebuild工具需要Xcode,但是是活动的 开发者目录'/Library/ developer /CommandLineTools'是一个命令 直线工具实例

有什么问题吗?


当前回答

我无需安装完整的Xcode应用程序就可以解决这个错误。但是,你必须安装xcode命令行工具。

从这里开始:

$ CD /usr/bin $ sudo mv xcodebuild xcodebuild。orig(以防万一的备份) $ vim xcodebuild 粘贴如下内容:

#!/bin/bash
if [[ $1 == '-version' ]]; then
  echo "Xcode 10.2.1"
  echo "Build version 10E1001"
else
  /usr/bin/xcodebuild.bak $@
fi

$sudo chmod +x xcodebuild

其他回答

我安装了两个Xcode实例。App和xcode-beta.app 当我试图用netbeans创建一个构建时,它向我显示了错误 支持的xcode版本和命令行工具没有找到netbeans

我遵循了以下步骤:

"xcode-select——print-path" = "/Applications/Xcode.app/Contents/Developer" " / / xcode /内容/应用开发人员/平台/ iPhoneSimulator。平台”的存在 "xcodebuild -version"以"Xcode"开头

after 1我发现它指向我到xcode-beta.app

下面是一个神奇的解决方案:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

对于那些不想安装Xcode的人,还有其他解决方案:

安装命令行工具(如果你还没有): xcode-select——安装 修改主目录: sudo xcode-select -switch /Library/Developer/CommandLineTools

这对我很管用(git)。

sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer

languoguangs-iMac:/ languoguang$ sudo xcode-select -s /Applications/Xcode 10.app/Contents/Developer
xcode-select: error: invalid argument '10.app/Contents/Developer'
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
languoguangs-iMac:/ languoguang$ sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"

因为我在应用程序中的Xcode名称是Xcode 10,

sudo xcode-select -s "/Applications/Xcode 10.app/Contents/Developer"

的工作原理。

请按以下步骤操作:

最新版本的Xcode可以从https://developer.apple.com/xcode/download/下载 除非另有说明,否则将在“下载”中下载。请确保检查你下载和提取Xcode的路径 现在不像其他下载的应用程序,在提取时,Xcode没有提供将其移动到应用程序的选项 注意XCODE-ACTUAL-LOCATION或将其移动到应用程序 注意你是否下载了Xcode或Xcode-beta

在4和5的基础上,执行其中一条命令(如果没有阅读上述说明,请不要执行所有命令):

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode.app/Contents/Developer
sudo xcode-select -s /[XCODE-ACTUAL-LOCATION]/Xcode-beta.app/Contents/Developer

我无需安装完整的Xcode应用程序就可以解决这个错误。但是,你必须安装xcode命令行工具。

从这里开始:

$ CD /usr/bin $ sudo mv xcodebuild xcodebuild。orig(以防万一的备份) $ vim xcodebuild 粘贴如下内容:

#!/bin/bash
if [[ $1 == '-version' ]]; then
  echo "Xcode 10.2.1"
  echo "Build version 10E1001"
else
  /usr/bin/xcodebuild.bak $@
fi

$sudo chmod +x xcodebuild