Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between swift and swiftc?

Tags:

macos

swift

What's the difference between swift and swiftc?

I've read some resources saying that swiftc is a symbolic link to swift, but this is not the case on macOS Mojave 10.14.6:

-rwxr-xr-x  1 root  wheel  18288 Jul 29 23:49 /usr/bin/swiftc

Both swift and swiftc contains OVERVIEW: Swift compiler as part of their --help menu, but while their options are similar, they are different.

like image 715
Shuzheng Avatar asked Sep 03 '19 18:09

Shuzheng


1 Answers

swift is an interactive environment (REPL) for Swift.

swiftc is the Swift compiler.

The files in /usr/bin are just redirectors to the currently selected version (based on xcode-select). If you look at the filesize you'll note these are only 18kB. They're not the real executables.

The actual version can be found using xcrun:

$ xcrun -f swift
/Applications/Xcode-beta7.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift

If you look in that directory, you'll see that swiftc is a symlink to swift (which is a 90MB executable). The executable just checks what name it was run as, and adjusts its behavior accordingly.

like image 110
Rob Napier Avatar answered Nov 07 '22 22:11

Rob Napier