Skip to content
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

macOS: Advise how to "uninstall any existing Swift installation(s)" #139

Open
BrianHenryIE opened this issue Jul 17, 2024 · 0 comments
Open

Comments

@BrianHenryIE
Copy link

BrianHenryIE commented Jul 17, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant