Why not publish the TOOLCHAINS setting?

I don't know what category to put this in, sorry. But every time I install a toolchain I want to use it from the command line I need to set the TOOLCHAINS environment variable, and I go through some awkward process in Xcode:Toolchains > Manage Toolchains… > hover over the right part of the toolchain in question and click the three dots > Show in Finder > ctrl click in finder > Show Package Contents > look in info.plist. Maybe there's a more straightforward method, but in that case the fact that it isn't easier to find is a problem: it should be on the Downloads page. And after all, why not just put the TOOLCHAINS setting in the text on the download page?

of looking in a plist file or opening xcode

3 Likes

Use this shell command, assuming you've selected "Install only for me" in the package installer GUI:

export TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw \
 ~/Library/Developer/Toolchains/swift-latest.xctoolchain/Info.plist)

Also mentioned on the macOS installation page on swift.org. One could argue that surfacing it more prominently can be useful, but up to swift.org website maintainers to make the final call, I reckon.

1 Like

Well I didn't. And I remember roughly what to do with Xcode, but won't remember that voodoo.

Agreed. Is there a better way to reach them than by posting here?

Then it's probably in /Library and not ~/Library, removing the tilde from the path in env var calculation might work, I just don't remember the exact path for global toolchain installations and can't verify it right now on the spot.

It can be saved in a script. But if the command stays in your shell history, then Ctrl-R to recall the command by substring (toolchain for example) may be good enough.

A PR or an issue on GitHub - apple/swift-org-website: Swift.org website could work.

If I understand correctly, I think swiftenv might help. I've been having pretty good luck with it and its available from brew. I don't have to go look at Xcode after doing a nightly install anymore. I just ask swiftenv what's available and switch to whichever one I want.

1 Like