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

pou*_*def 63 xcode xcode-command-line-tools

当我尝试运行该clang命令时,出现以下错误:

\n
xcode-select: Failed to locate \'clang\', requesting installation of command line developer tools.\n
Run Code Online (Sandbox Code Playgroud)\n

然后我收到这个弹出窗口:

\n

clang 安装弹出窗口

\n

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

\n

我也尝试过运行xcode-select --install,但是出现以下错误:

\n
xcode-select: error: command line tools are already installed, use "Software Update" to install updates\n
Run Code Online (Sandbox Code Playgroud)\n

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

\n

我使用的是运行 macOS Monterey 版本 12.5 的 M1 mac。

\n

它还会产生一个核心转储:

\n
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)\n  Referenced from: \'/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability\'\n  Expected in: \'/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator\'" UserInfo={NSLocalizedFailureReason=The bundle couldn\xe2\x80\x99t 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)\n  Referenced from: \'/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability\'\n  Expected in: \'/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator\', NSBundlePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin, NSLocalizedDescription=The bundle \xe2\x80\x9cIDESimulatorAvailability\xe2\x80\x9d couldn\xe2\x80\x99t be loaded.}, dyldError = dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0000): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)\n  Referenced from: \'/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability\'\n  Expected in: \'/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator\'\n2022-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\nDetails:  Failed to load code for plug-in com.apple.dt.IDESimulatorAvailability (/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin)\nPlease ensure Xcode packages are up-to-date \xe2\x80\x94 try running \'xcodebuild -runFirstLaunch\'.\n\nNSBundle error: Error Domain=NSCocoaErrorDomain Code=3588 "dlopen(/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability, 0x0109): Symbol not found: (_OBJC_CLASS_$_SimDiskImage)\n  Referenced from: \'/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability\'\n  Expected in: \'/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator\'" UserInfo={NSLocalizedFailureReason=The bundle couldn\xe2\x80\x99t 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)\n  Referenced from: \'/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin/Contents/MacOS/IDESimulatorAvailability\'\n  Expected in: \'/Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/CoreSimulator\', NSBundlePath=/Applications/Xcode.app/Contents/PlugIns/IDESimulatorAvailability.ideplugin, NSLocalizedDescription=The bundle \xe2\x80\x9cIDESimulatorAvailability\xe2\x80\x9d couldn\xe2\x80\x99t be loaded.}\nObject:   <DVTPlugIn: 0x60000080b7a0>\nMethod:   -loadAssertingOnError:error:\nThread:   <_NSMainThread: 0x600002c402c0>{number = 1, name = main}\nHints:\n\nBacktrace:\n  0  0x000000010653d410\n  1  0x000000010653caec\n  2  0x000000010653cc6c\n  3  0x00000001063eb2ac\n  4  0x00000001063b1118\n  5  0x00000001063af528\n  6  0x0000000181aa01b4\n  7  0x0000000181aaf414\n  8  0x000000010658158c\n  9  0x000000010655d4b0\n 10  0x00000001063af3c0\n 11  0x00000001063af5e0\n 12  0x00000001074372ec\n 13  0x0000000107436ae0\n 14  0x00000001074361e8\n 15  0x0000000104c70324\n 16  0x0000000104c21e0c\nsh: 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\nclang: 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)\n
Run Code Online (Sandbox Code Playgroud)\n

如何安装 clang?

\n

小智 123

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

\n

这对我有用。

\n


Sno*_*ber 13

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

\n

有效的方法是在更新后打开 Xcode 并接受加载基本开发工具的提示(适用于 macOS 和 iOS)。

\n

错误消息中还隐藏了 CLI 解决方案:“请确保 Xcode 包是最新的 \xe2\x80\x94,尝试运行 ' xcodebuild -runFirstLaunch'。”

\n