新的 OS X Mavericks 升级后出现 git 错误“无法找到 xcodebuild”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19647788/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:12:50  来源:igfitidea点击:

git error "unable to locate xcodebuild" after a fresh OS X Mavericks upgrade

gitxcodebuildosx-mavericks

提问by tol4trob

When I try to run previously working git commands, I get this:

当我尝试运行以前工作的 git 命令时,我得到这个:

dyld: Symbol not found: _sqlite3_intarray_bind
  Referenced from: /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
  Expected in: /opt/local/lib/libsqlite3.dylib
 in /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
git: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
git: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch

How can I fix this?

我怎样才能解决这个问题?

回答by sushilprj

This works for me sudo xcode-select --switch /Library/Developer/CommandLineTools/

这对我有用 sudo xcode-select --switch /Library/Developer/CommandLineTools/

回答by tol4trob

After a much googling and confusion, the following steps lead to a solution (with Xcode installed). Some might be optional, so please feel free to elaborate on this as I am not an expert on these errors.

经过大量的谷歌搜索和混淆后,以下步骤导致了一个解决方案(安装了 Xcode)。有些可能是可选的,所以请随意详细说明这一点,因为我不是这些错误的专家。

  • download mavericks command line tools https://developer.apple.com/downloads/
  • xcode-select --install
  • sudo xcode-select -switch /Library/Developer/CommandLineTools
  • brew install sqlite3
  • commented out DYLD_LIBRARY_PATHentry in my .bashrcfile
  • 下载小牛命令行工具https://developer.apple.com/downloads/
  • xcode-select --install
  • sudo xcode-select -switch /Library/Developer/CommandLineTools
  • brew install sqlite3
  • 注释掉DYLD_LIBRARY_PATH.bashrc文件中的条目

回答by theandrewlane

On MacOS Mojave this worked for me (git 2.21.0):

在 MacOS Mojave 上,这对我有用(git 2.21.0):

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

回答by zdk

If you have already installed Xcode, you can run the following command to determine and point to the correct location

如果你已经安装了Xcode,你可以运行下面的命令来确定并指向正确的位置

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

Or use AppStore to install latest Xcode.

或者使用 AppStore 安装最新的 Xcode。

回答by aregjan

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

This did it for me.

这为我做到了。

回答by answerzilla

Most likely you need to reinstall the command line tools before switching the xcode path to point there.

在将 xcode 路径切换到指向那里之前,您很可能需要重新安装命令行工具。

First install the tools

首先安装工具

$ xcode-select --install

$ xcode-select --install

This will install the tools into the folder /Library/Developer/CommandLineTools.

这会将工具安装到文件夹中/Library/Developer/CommandLineTools

Then point the xcode path to where the tools were installed, like this

然后将xcode路径指向安装工具的位置,像这样

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

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

Note: You can see the current xcode path with the command $ xcode-select -p. Mine was initially pointing to /Applications/Xcode.app/Contents/Developerwhen I was getting the error

注意:您可以使用命令查看当前的 xcode 路径$ xcode-select -p。我的最初是指/Applications/Xcode.app/Contents/Developer我收到错误时

回答by NANA

I met this error when i run the command 'git clone xxx'

当我运行命令“git clone xxx”时遇到了这个错误

dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild Reason: image not found git: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly! git: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch

dyld:库未加载:@rpath/libswiftCore.dylib 引用自:/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild 原因:找不到图像 git:错误:无法定位 xcodebuild,请确定路径到 Xcode 文件夹设置正确!git: 错误:您可以使用 /usr/bin/xcode-select -switch 设置 Xcode 文件夹的路径

Then, run the command

然后,运行命令

xcode-select -p

pointing to /Applications/Xcode.app/Contents/Developer

指向 /Applications/Xcode.app/Contents/Developer

After run the command sudo xcode-select -switch /Library/Developer/CommandLineTools

运行命令后 sudo xcode-select -switch /Library/Developer/CommandLineTools

it points to /Library/Developer/CommandLineTools

它指向 /Library/Developer/CommandLineTools

回答by wanton

I hit this same issue running Fastlane on a fresh High Sierra installation. Solved with:

我在全新的 High Sierra 安装上运行 Fastlane 时遇到了同样的问题。解决了:

sudo xcode-select --switch /Applications/Xcode.app

回答by J Knowles

This worked for me in MacOS High Sierra (10.13.6)

这在 MacOS High Sierra (10.13.6) 中对我有用

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

须藤 xcode-select --switch /Library/Developer/CommandLineTools/

回答by Kalena Galarnyk

This worked for me, just paste in terminal: sudo xcode-select --switch /Library/Developer/CommandLineTools/

这对我有用,只需粘贴在终端中: sudo xcode-select --switch /Library/Developer/CommandLineTools/