The Swift Package Manager (SPM) is a tool for creating Swift applications and managing their dependencies. SPM supports Executable and Library projects and is included as part of the Swift installation.
To make a new Swift application, setup a folder for the project.
$ mkdir -p ~/swift/hello
$ cd ~/swift/hello
We can create a CLI (Command Line Interface) application with SPM using the
$ swift package init --type executable
View the applications folder structure with tree*.
$ tree . -- Package.swift -- README.md -- Sources -- hello -- main.swift -- Tests -- LinuxMain.swift -- helloTests -- XCTestManifests.swift -- helloTests.swift 4 directories, 6 files
Run the compiled application.
$ swift build
$ swift run
The compiled binary is located in a hidden folder under
.build and can be executed directly.
To finish up, create a git repository and make the initial commit.
$ git init
$ git add .
$ git commit -am "Initial commit"
That is an introduction to Swift Package Manager, though there is still more to learn about dependency management.
* Install Tree
$ sudo apt install tree
Swift Package Manager Documentation