owensd / vscode-swift

An extension for VS Code which provides support for the Swift language.
MIT License
147 stars 5 forks source link

Toolchain lookup is broken in v0.7.0. #8

Closed owensd closed 7 years ago

owensd commented 7 years ago

For some reason, this code isn't working properly:

        let settings = (params.settings as! JSValue)[languageServerSettingsKey]

        guard let toolchainPath = settings["toolchainPath"].string else {
            throw "The path to the Toolchain must be set."
        }
        self.toolchainPath = toolchainPath
        log("configuration: toolchainPath set to %{public}@", category: languageServerLogCategory, toolchainPath)

        self.packagePath = "\(projectPath!)/Package.swift"
        self.includePath = "\(toolchainPath)/usr/lib/swift/pm"
        self.swiftPath = "\(toolchainPath)/usr/bin/swift"

Need to look into why the proper settings dictionary isn't being retrieved.

owensd commented 7 years ago

The work-around for now is to create a link in your /Library/Developer/Toolchains directory.

cd /Library/Developer
sudo mkdir Toolchains
cd Toolchains
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain swift-latest.xctoolchain

This is only necessary if you're using the Xcode version of Swift instead of the toolchain drops.

owensd commented 7 years ago

Looking at this again, I forgot to save the changes to settings.json. The simple workaround of setting the swift.toolchainPath does work.

Add this to your settings.json file:

"swift.toolchainPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain swift-latest.xctoolchain"
owensd commented 7 years ago

Should be fixed in v0.8.0.