2017-04-14 38 views
5

我最近重新格式化我的Mac。今天,我嘗試通過Terminal建立一個快速的可執行文件來啓動一個服務器端的swift項目。下面是我用的命令:運行在終端斯威夫特構建導致「平臺路徑」錯誤

  1. 迅速包初始化--type可執行

  2. 迅速構建

在運行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

在此先感謝!

回答

14

嘗試固定SDK路徑(你出現不正確的):通過調用

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

交換機的默認SDK位置:

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

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

你可能有這樣的結果如果這不起作用,請查看(正常)SDK路徑:

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

您應該看到在該目錄中SDK的;如果沒有,你需要下載它們。

0

選擇版本的Xcode可以通過運行運行swift build命令,例如:

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