首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >即使在安装了命令行工具之后,xcode-select也无法找到clang。

即使在安装了命令行工具之后,xcode-select也无法找到clang。
EN

Stack Overflow用户
提问于 2022-09-19 15:03:59
回答 4查看 7K关注 0票数 60

当我尝试运行clang命令时,会得到以下错误:

代码语言:javascript
运行
复制
xcode-select: Failed to locate 'clang', requesting installation of command line developer tools.

然后我收到了这个弹出式:

然而,无论我点击多少次“安装”--经过15分钟的安装过程--我仍然会得到相同的错误。

不过,我也尝试过运行xcode-select --install,但这会导致以下错误:

代码语言:javascript
运行
复制
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

我也尝试过从这里手动安装。

我用的是M1 mac,运行的是macOS蒙特雷12.5版。

它还产生一个核心转储:

代码语言:javascript
运行
复制
2022-09-19 10:51:04.669 xcodebuild[1541:17443] [MT] DVTPlugInLoading: Failed to load code for plug-in com.apple.dt.IDESimulatorAvailability (/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin), error = Error Domain=NSCocoaErrorDomain Code=3588 "dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
  Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
  Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator'" UserInfo={NSLocalizedFailureReason=The bundle couldn’t be loaded., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, NSDebugDescription=dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
  Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
  Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator', NSBundlePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin, NSLocalizedDescription=The bundle “IDESimulatorAvailability” couldn’t be loaded.}, dyldError = dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0000): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
  Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
  Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator'
2022-09-19 10:51:04.688 xcodebuild[1541:17443] [MT] DVTAssertions: ASSERTION FAILURE in /System/Volumes/Data/SWE/Apps/DT/BuildRoots/BuildRoot2/ActiveBuildRoot/Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-21303/DVTFoundation/PlugInArchitecture/DataModel/DVTPlugIn.m:374
Details:  Failed to load code for plug-in com.apple.dt.IDESimulatorAvailability (/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin)
Please ensure Xcode packages are up-to-date — try running 'xcodebuild -runFirstLaunch'.

NSBundle error: Error Domain=NSCocoaErrorDomain Code=3588 "dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
  Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
  Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator'" UserInfo={NSLocalizedFailureReason=The bundle couldn’t be loaded., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, NSDebugDescription=dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)
  Referenced from: '/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability'
  Expected in: '/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator', NSBundlePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin, NSLocalizedDescription=The bundle “IDESimulatorAvailability” couldn’t be loaded.}
Object:   <DVTPlugIn: 0x60000080b7a0>
Method:   -loadAssertingOnError:error:
Thread:   <_NSMainThread: 0x600002c402c0>{number = 1, name = main}
Hints:

Backtrace:
  0  0x000000010653d410
  1  0x000000010653caec
  2  0x000000010653cc6c
  3  0x00000001063eb2ac
  4  0x00000001063b1118
  5  0x00000001063af528
  6  0x0000000181aa01b4
  7  0x0000000181aaf414
  8  0x000000010658158c
  9  0x000000010655d4b0
 10  0x00000001063af3c0
 11  0x00000001063af5e0
 12  0x00000001074372ec
 13  0x0000000107436ae0
 14  0x00000001074361e8
 15  0x0000000104c70324
 16  0x0000000104c21e0c
sh: line 1:  1543 Abort trap: 6           /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find clang 2> /dev/null
clang: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find clang 2> /dev/null' failed with exit code 34304: (null) (errno=Invalid argument)

如何安装clang?

EN

回答 4

Stack Overflow用户

发布于 2022-09-19 18:57:47

请确保Xcode包是最新的-尝试运行xcodebuild -runFirstLaunch.

这对我有用。

票数 118
EN

Stack Overflow用户

发布于 2022-09-20 09:50:38

我也有同样的问题,更新了Xcode,重新链接的路径等等,这并没有帮助。

起作用的是在更新后打开Xcode,并接受加载必要的开发工具(对于macOS和iOS)的提示。

错误信息中隐藏的一点是CLI解决方案:“请确保Xcode包是最新的-尝试运行‘xcodebuild -runFirstLaunch’。”

票数 13
EN

Stack Overflow用户

发布于 2022-09-20 21:40:24

您也可以打开Xcode,选择默认的运行时工具(在我的例子中是MacOS和iOS ),然后clang应该正常运行。

我相信这和做@Lander与否的回答是一样的,但无法证实。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73775528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档