lostAtSeaJoshua lostAtSeaJoshua - 11 months ago 92
iOS Question

How to fix DVTToolchain: Failed to load toolchain using Xcode command line tools?

Anytime I run any command with

in the terminal it always outputs:

VTToolchain: Failed to load toolchain: : Error Domain=DVTToolchainErrorDomain Code=4 "alleged toolchain directory doesn't contain ToolchainInfo.plist or Info.plist" UserInfo={NSFilePath=/Library/Developer/Toolchains/swift-latest.xctoolchain, NSLocalizedDescription=alleged toolchain directory doesn't contain ToolchainInfo.plist or Info.plist}

I have opened the /Toolchains/switft-latest.xctoolchain and it contains Toolchain.Info.plist, so I am confused on how to fix this error. I have tried reinstalling Xcode and reinstalling Xcode command tools

These are my SDK paths:

xcode-select -p

xcrun --show-sdk-path

Answer Source

I fixed the issue by removing the link to the latest toolchain in Library/Developer/Toolchains.

$ cd /Library/Developer/Toolchains/
$ ls -l
$ -rw-r--r--@ 1 user  admin  1268976 Sep  3 04:43 swift-latest.xctoolchain
$ rm swift-latest.xctoolchain

I ran xcodebuild right after and I had no error. The issue was from previously downloading a new toolchain and Xcode didn't remove it correctly when I uninstalled it. I had help from this github issue.