xcode 在终端中运行Swift build导致“平台路径”错误

nmpmafwu  于 2023-05-30  发布在  Swift
关注(0)|答案(2)|浏览(228)

我最近重新格式化了我的Mac。今天,我尝试通过终端构建一个swift可执行文件来启动一个服务器端的swift项目。以下是我使用的命令:
1.swift包init --type可执行文件
1.快速构建
在运行swift build时,我得到了以下错误:

xcrun: error: unable to lookup item 'PlatformPath' from command line tools installation
xcrun: error: unable to lookup item 'PlatformPath' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'

我运行的是Xcode 8.3.1
先谢谢你了!

dgsult0t

dgsult0t1#

尝试修复SDK路径(您的路径似乎不正确):

$ xcrun --show-sdk-path --sdk macosx

你可能会得到这样的结果:

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

通过调用以下命令切换默认SDK位置:

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

如果这不起作用,请查看(正常)SDK路径:

$ ls -lat /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/

您应该可以在该目录中看到SDK;如果没有,你需要下载它们。

pobjuy32

pobjuy322#

选择一个可以运行swift build命令的Xcode版本,例如:

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

其中Xcode-8.3.3是Xcode应用程序的名称

相关问题