-
Notifications
You must be signed in to change notification settings - Fork 71
Use Swiftly's toolchain path if active toolchain is managed by Swiftly #1470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Swiftly's toolchain path if active toolchain is managed by Swiftly #1470
Conversation
On macOS the toolchain path is determined by `xcrun --find swift`. `xcrun` will return paths inside the active Xcode. If the active toolchain is being managed by the newly released Swiftly 1.0 on macOS then the swift path and the toolchain path will be mismatched. Check to see if the active toolchain is managed by Swiftly, and if so point the toolchain path to the Swiftly installed toolchain. The name of the `.xctoolchain` folder needs to be reverse engineered from Swiftly's in use toolchain name using the ToolchainVersion.parse method which was ported from Swiftly's codebase. A nice feature in the future would be to be able to ask Swiftly where its managed toolchains are stored on disk.
os.homedir(), | ||
"Library/Developer/Toolchains/", | ||
`${version.identifier}.xctoolchain`, | ||
"usr" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Should this be a path to the <toolchain>/usr/bin
where the binaries like swift
are located?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other toolchain paths in VS Code they're specified as name.xctoolchain/usr
const version = ToolchainVersion.parse(swiftlyConfig.inUse); | ||
return path.join( | ||
os.homedir(), | ||
"Library/Developer/Toolchains/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Should this toolchain function indicates that it is macOS-only?
if (swiftlyHomeDir) { | ||
const { stdout: swiftLocation } = await execFile("which", ["swift"]); | ||
if (swiftLocation.indexOf(swiftlyHomeDir) === 0) { | ||
const swiftlyConfig = await SwiftToolchain.getSwiftlyConfig(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: For the in use toolchain, swiftly has a swiftly use --print-location
command that will give the filesystem path of the one that's in-use. It can be more expensive than reading the config.json, but it also takes into consideration toolchains that are in-use because of the .swift-version
file.
On macOS the toolchain path is determined by
xcrun --find swift
.xcrun
will return paths inside the active Xcode. If the active toolchain is being managed by the newly released Swiftly 1.0 on macOS then the swift path and the toolchain path will be mismatched.Check to see if the active toolchain is managed by Swiftly, and if so point the toolchain path to the Swiftly installed toolchain. The name of the
.xctoolchain
folder needs to be reverse engineered from Swiftly's in use toolchain name using the ToolchainVersion.parse method which was ported from Swiftly's codebase. A nice feature in the future would be to be able to ask Swiftly where its managed toolchains are stored on disk.