Installing Vapor 3

Quick(-ish) reference guide to installing Vapor 3

Why Vapor?

Being able to write Swift on the client and server is another nice example of the 'Learn once, apply everywhere' philosophy embodied in technologies such as SwiftUI.

Up to this point, writing Vapor apps required careful juggling of Xcode, Swift, and Vapor versions, but this is starting to settle down a bit, although with Vapor 4 set to be released soon it might all change again.

Preflight Swift Version

Preflight the version of Swift that is installed:

swift --version

Vapor requires a minimum of Swift 4.1, at time of writing the installed version was 5.1

Install Brew

Installing Vapor currently requires brew, a package manager that is probably not already installed (Back in Vapor 2 it relied on apt instead of brew; not sure why there was a change). Check to see if brew is installed:

which brew

If it returns 'brew not found' then brew needs to be installed (from the instructions at Homebrew):

/usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"

There may be warnings about lack of support for macOS 10.15 at this time.

Install vapor

Now that brew is installed we can install vapor:

brew tap vapor/tap
brew install vapor/tap/vapor

Install Xcode Command Line Tools

Install the Command Line Tools:

xcode-select --install

Verify vapor installation

Now that vapor installation has completed we can check:

vapor --version

This should return the installed version of vapor, at time of writing the installed version was 3.1.10.

Verify Xcode, Vapor, and Swift compatibility

There's a useful script that identifies any compatibility problems between Xcode, Vapor, and Swift:

eval \"$(curl -sL check.vapor.sh)\"

This should report the compatibility status:

? Xcode 9.3 or later is compatible with Vapor 3
? Xcode 11.0 or later is compatible with Vapor 4
? Swift 4.1 or later is compatible with Vapor 3
? Swift 5.1 or later is compatible with Vapor 4

Summary

Assuming brew and vapor installed successfully, and assuming that the compatibility scripts shows that the installed versions of Xcode and Swift are compatible with the desired version of Vapor, then we should be good to go.

Resources

Vapor's website.

Vapor's 'Install on macOS' documentation.

Brew's website.