在终端中运行 Swift 构建导致“平台路径";错误 [英] Running Swift build in Terminal leading to "Platform Path" errors
问题描述
我最近重新格式化了我的 Mac.今天我尝试通过终端构建一个 swift 可执行文件来启动一个服务器端 swift 项目.以下是我使用过的命令:
I recently reformatted my Mac. Today I tried building a swift executable via Terminal to start a server-side swift project. Here are the commands I've used:
swift package init --type executable
快速构建
运行 swift build
后,出现以下错误:
Upon running swift build
, I got the following errors:
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.
提前致谢!
推荐答案
尝试修复 SDK 路径(您的似乎不正确):
Try fixing the SDK path (yours appears incorrect):
$ xcrun --show-sdk-path --sdk macosx
你可能会得到这样的结果:
You might have this result:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
通过调用切换默认 SDK 位置:
Switch the default SDK location by invoking:
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
如果这不起作用,请查看(正常)SDK 路径:
If that doesn't work then take a look inside the (normal) SDK path:
$ ls -lat /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
您应该会在该目录中看到 SDK;如果没有,您需要下载它们.
You should see the SDK's within that directory; if not you'll need to download them.
这篇关于在终端中运行 Swift 构建导致“平台路径";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!