-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
When I run swiftly-install.sh
it helpfully says:
Warning: existing installation of Swift detected at /usr/bin/swift
To ensure swiftly-installed toolchains can be found by the shell, uninstall any existing Swift installation(s).
My existing setup:
% cat ~/.zshrc
...
# Use /Library/Developer/Toolchains/ rather than /usr/bin/swift
#export TOOLCHAINS=swift
export TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw /Library/Developer/Toolchains/swift-latest.xctoolchain/Info.plist)
% which swift
/usr/bin/swift
% swift --version
Apple Swift version 6.0-dev (LLVM 0ad8ad0245d47b4, Swift 5916325b39fe7a5)
Target: arm64-apple-macosx14.0
% ls -l /Library/Developer/Toolchains/
total 0
drwxr-xr-x 7 root wheel 224 Jul 15 17:17 swift-5.10.1-RELEASE.xctoolchain
drwxr-xr-x 7 root wheel 224 Jul 13 13:54 swift-DEVELOPMENT-SNAPSHOT-2024-07-11-a.xctoolchain
lrwxr-xr-x 1 root wheel 81 Jul 16 21:43 swift-latest.xctoolchain -> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-07-11-a.xctoolchain
To use the swiftly installed Swift version, I just had to remove the export TOOLCHAINS=
line from my .zshrc
.
It would be nice to scan the file for that line to advise clearly what needs to be changed.
After:
% which swift
/Users/brianhenry/Library/Application Support/swiftly/bin/swift
% swift --version
Apple Swift version 5.7.3 (swift-5.7.3-RELEASE)
Target: arm64-apple-macosx14.0
% swiftly list
Installed release toolchains
----------------------------
Swift 5.7.3 (in use)
Installed snapshot toolchains
-----------------------------
% ls -l ~/Library/Developer/Toolchains
total 0
drwxr-xr-x 7 brianhenry staff 224 Jul 16 21:31 swift-5.7.3-RELEASE.xctoolchain
lrwxr-xr-x 1 brianhenry staff 78 Jul 16 21:31 swift-latest.xctoolchain -> /Users/brianhenry/Library/Developer/Toolchains/swift-5.7.3-RELEASE.xctoolchain
The check is basically:
if [ -n "`$SHELL -c 'echo $ZSH_VERSION'`" ]; then
if [[ $(cat "$HOME/.zshrc" | grep -e "^\s*export TOOLCHAINS=") ]]; then
echo "TOOLCHAINS is set in ~/.zshrc"
else
echo "TOOLCHAINS is NOT set in ~/.zshrc"
fi
fi
Metadata
Metadata
Assignees
Labels
No labels