Ubuntu 16.04 使用 Swift

本文介绍了在 Ubuntu 16.04 上使用 Swift。

官方网站:https://swift.org/

安装依赖

1
$ sudo apt install clang libicu-dev

下载解压

请到官方网站复制链接下载。

之后将文件的 /swift_path/usr/bin 路径加入 PATH

简单使用

Hello World!

编写 hello.swift 文件。

1
printf("Hello, World!")

编译,执行

1
2
3
4
5
$ swiftc hello.swift

$ ./hello

Hello, World!
0%