Swift Programming

Swift is a programming language that has originally been created to make applications for Apple products like iPhone.

The best way to write and test Swift programs is to use a macOS computer with the latest version of the Xcode development tool.

This page provides some links and simple programs for you to start learning the Swift language.

Although the main purpose of Swift is to do GUI (Graphical User Interface) programming, it is possible to write Swift programs that can be run from the command line in a Terminal window.

The simple programs listed in the table are such CLI (Command Line Interface) programs. Swift version 3 was used to make those programs. More instructions below.



How to execute the above programs?

After you have installed the Xcode development tool, it will be possible to use the Terminal app of macOS to execute the above CLI programs. When you install Xcode, you must start the tool to make the installation complete. Later on you do not need to activate Xcode to run the CLI programs.

You can download the above programs by Ctrl-clicking or Right-clicking the links, the file names. For example, if you download the file Game.swift and put it into a subfolder named swiftwork inside the Documents folder, you should be able to execute the program with the following commands in a Terminal window.

         cd Documents
         cd swiftwork

         xcrun swift Game.swift

Open Source Swift

In December 2015 the Swift programming language has been released as an open source language. This means that Swift may be available on non-Apple platforms.