【问题标题】:xcrun: error: unable to find utility "xctest", not a developer tool or in PATHxcrun:错误:无法找到实用程序“xctest”,不是开发人员工具或 PATH
【发布时间】:2020-08-13 12:17:08
【问题描述】:

我在我的 MAC 中使用 Xcode 命令行工具而不是 XCode 应用程序。 当我使用swift --version 我得到Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51) 我用

克隆了一个项目
git clone https://github.com/apple/example-package-dealer.git
cd example-package-dealer
swift run Dealer

我给了我这个错误:

error: terminated(72): OLDPWD=/Users/sayansen/Work/EdgeAnalytics/Trial TERM_PROGRAM=Apple_Terminal PWD=/Users/sayansen/Work/EdgeAnalytics/Trial/example-package-dealer SHLVL=1 SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.9lwBmlYTAx/Listeners HOME=/Users/sayansen LIBRARY_PATH=/usr/local/lib __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0 XPC_SERVICE_NAME=0 TMPDIR=/var/folders/kn/v4zm474x52n8zrycxs7nh5c40000gn/T/ LOGNAME=sayansen SHELL=/bin/bash TERM_PROGRAM_VERSION=433 _=/usr/bin/swift PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS CPATH=/usr/local/include SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk XPC_FLAGS=0x0 TERM=xterm-256color USER=sayansen LC_CTYPE=UTF-8 TERM_SESSION_ID=B285E686-2802-48C6-B8CE-03CA8F2314BF xcrun --sdk macosx --find xctest output:
xcrun: error: unable to find utility "xctest", not a developer tool or in PATH

我没有使用 XCODE。 我已经这样做了:

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

但没有帮助。

如何在不安装 XCode 的情况下解决此错误?

【问题讨论】:

  • 我在这里找到了xctest:/Applications/Xcode.app/Contents/Developer/usr/bin/xctest,看来你必须安装XCode才能拥有它。
  • @Philippe 哦,没有别的办法了吗?我避免安装 xcode

标签: swift xcode macos xctest xcode-command-line-tools


【解决方案1】:

假设你已经安装了 Xcode:

启动 Xcode,选择“Preferences -> Locations”。可能是您的命令行工具未设置。选择建议的 Xcode-tools 位置即可。

补充:

您可以检查:

xcode-select -p

设置了哪些工具,我的显示:

/Library/Developer/CommandLineTools

设置好偏好中的位置后,显示:

/Applications/Xcode.app/Contents/Developer

(应该如此)

【讨论】:

  • 虽然接受了答案,但它没有解决原始约束,即:“如何在不安装 XCode 的情况下解决此错误?”。要回答这个问题,目前无法仅使用命令行工具来构建/运行/测试 SPM 包。
【解决方案2】:

Xcode -> 首选项(或 command+,

位置选项卡 -> 命令行工具部分: 在那里选择一个工具,你就完成了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-18
    • 1970-01-01
    • 2020-06-07
    • 2017-04-06
    • 2019-04-11
    • 2017-08-21
    • 2018-12-07
    • 2019-05-09
    相关资源
    最近更新 更多