tags:
- Notes
Getting Started with Swiftly on Linux
You need at first download swiftly for Linux, swift has a document for this:
curl -O https://download.swift.org/swiftly/linux/swiftly-1.0.0-$(uname -m).tar.gz
Extract the archive:
tar -zxf swiftly-1.0.0-$(uname -m).tar.gz
and then initialize it:
du@DVM:~$ ./swiftly init
Swiftly will be installed into the following locations:
/home/du/snap/code/184/.local/share/swiftly - Data and configuration files directory including toolchains
/home/du/.local/share/swiftly/bin - Executables installation directory
These locations can be changed with SWIFTLY_HOME_DIR and SWIFTLY_BIN_DIR environment variables and run this again.
Once swiftly is installed it will install the latest available swift toolchain. In the process of installing the new toolchain swiftly will add swift.org GnuPG keys into your keychain to verify the integrity of the downloads.
Proceed? (Y/n):
y
Installing swiftly in /home/du/.local/share/swiftly/bin/swiftly...
Creating shell environment file for the user...
Updating profile...
Fetching the latest stable Swift release...
Installing Swift 6.1.0
Downloading Swift 6.1.0
100% [===============================================================================================================================================]
Downloaded 838.4 MiB of 838.4 MiB
Verifying toolchain signature...
Extracting toolchain...
The global default toolchain has been set to `Swift 6.1.0`
Swift 6.1.0 installed successfully!
To begin using installed swiftly from your current shell, first run the following command:
# Added by swiftly
. "/home/du/snap/code/184/.local/share/swiftly/env.sh"
Your shell caches items on your path for better performance. Swiftly has added items to your path that may not get picked up right away. You can run this command to update your shell to get these items.
hash -r
There are some dependencies that should be installed before using this toolchain.
You can run the following script as the system administrator (e.g. root) to prepare
your system:
apt-get -y install gnupg2 libpython3-dev libxml2-dev libz3-dev pkg-config python3-lldb-13
在初始化的时候,swiftly 提醒我在使用 swiftly 之前,运行这几条命令:
# Load env variable at current shell
. "/home/du/snap/code/184/.local/share/swiftly/env.sh"
# Refreshing cache
hash -r
# Download dependencies
apt-get -y install gnupg2 libpython3-dev libxml2-dev libz3-dev pkg-config python3-lldb-13
把 Swift 的路径和环境变量添加到系统的 PATH
中,实现全局使用。
du@DVM:~$ echo 'export PATH="$HOME/.local/share/swiftly/bin:$PATH"' >> ~/.bashrc
du@DVM:~$ echo 'source /home/du/snap/code/184/.local/share/swiftly/env.sh' >> ~/.bashrc
du@DVM:~$ source ~/.bashrc
第一行 Swift 代码:
print("Hello")
swift myProc.swift
SwiftUI 只能在 Mac 上用。。。