无法从 Xcode 获取模拟器列表。请打开 Xcode 并尝试直接从那里运行项目以解决剩余问题

Jos*_*i G 6 macos xcode ios react-native xcode-command-line-tools

我将操作系统 12.3 更新到 13.1,将 xcode 13.1 更新到 14.1 并安装了命令行工具,通过 xcode 运行本机应用程序,但不使用命令行运行,出现以下错误

    2022-12-13 16:36:47.584 xcodebuild[3616:20381] Writing error result bundle to /var/folders/zn/6l6295m57kb3vn_8pyn8xtbr0000gn/T/ResultBundle_2022-13-12_16-36-0047.xcresult
xcodebuild: error: SDK "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk" cannot be located.
xcrun: error: Failed to determine realpath of '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk' (errno=No such file or directory)
xcrun: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -find simctl 2> /dev/null' failed with exit code 16384: (null) (errno=No such file or directory)
xcrun: error: unable to find utility "simctl", not a developer tool or in PATH
error Could not get the simulator list from Xcode. Please open Xcode and try running project directly from there to resolve the remaining issues.
Error: Command failed: xcrun simctl list --json devices
2022-12-13 16:36:47.584 xcodebuild[3616:20381] Writing error result bundle to /var/folders/zn/6l6295m57kb3vn_8pyn8xtbr0000gn/T/ResultBundle_2022-13-12_16-36-0047.xcresult
xcodebuild: error: SDK "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk" cannot be located.
xcrun: error: Failed to determine realpath of '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk' (errno=No such file or directory)
xcrun: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -find simctl 2> /dev/null' failed with exit code 16384: (null) (errno=No such file or directory)
xcrun: error: unable to find utility "simctl", not a developer tool or in PATH

    at checkExecSyncError (node:child_process:828:11)
    at Object.execFileSync (node:child_process:863:15)
Run Code Online (Sandbox Code Playgroud)

但是如果export SDKROOT=$(xcrun -sdk macosx --show-sdk-path)在运行之前运行此命令react-native run-ios,反应本机应用程序运行正常,如果我关闭终端并再次运行反应本机应用程序,它会再次显示相同的错误

我尝试了这些步骤

sudo xcode-select --reset
sudo xcode-select --install
Run Code Online (Sandbox Code Playgroud)

Jos*_*i G 9

嗨,我终于发现了这个问题,我的.zshrc文件指向旧的 sdk,我删除了文件SDKROOT中的路径.zshrc并在终端中运行export SDKROOT=$(xcrun -sdk macosx --show-sdk-path),问题为我解决了

在此输入图像描述


小智 6

我遇到了同样的问题并通过以下步骤解决了它。

  1. 打开Xcode

  2. 转到首选项

  3. 转到位置选项卡

  4. 在标有“命令行工具”的选项中选择 Xcode 版本

  • 我的 Xcode 14 首选项显示选择了正确的版本,但再次选择它使事情开始工作,这毫无意义。 (2认同)