How to run Swift from the CLI

So far I’ve only had experience of running Swift from Xcode as part of a project. But you can also run and compile Swift independently of Xcode. Example:

$ echo 'print("hello")' > hello.swift
$ swift hello.swift
hello
$ swiftc hello.swift
$ ./hello
hello
👋 I'm Jim, a full-stack product engineer. Want to build an amazing product and a profitable business? Read more about me or Get in touch!

More by Jim

Tagged . All content copyright James Fisher 2017. This post is not associated with my employer. Found an error? Edit this page.