Vapor is a Swift framework for building web services, which makes accomplishing common tasks very easy. Vapor is currently at Version 2, which is compatible with Swift 4; more information about Vapor can be found on its website at http://vapor.codes.
For this recipe, we will assume that you are developing your Swift web service on a Mac, even if it may eventually be deployed to a Linux server.
Let's verify that our system is ready to run Vapor; if you have tried any previous recipe, it should be. Run the following command in the Terminal to check for Vapor compatibility:
eval "$(curl -sL check.vapor.sh)"
We will need to install the Vapor toolbox, which is a set of command-line tools to simplify working with Vapor based projects. The Vapor CLI is available through Homebrew, which is a package manager for macOS; you can find more details about Homebrew at https://brew.sh.
If you don't already have Homebrew installed, run the following in the Terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
With Homebrew installed, we can add the tap for Vapor:
brew tap vapor/homebrew-tap
Then, update Homebrew with the information from this new tap:
brew update
Let's run Vapor to check whether it's installed correctly. You should see instructions on how to use Vapor:
vapor version
We will create a web service to store and manage tasks from an iOS app. So, let's create a new Vapor project called TaskAPI and move to the new folder created:
vapor new TaskAPI
cd TaskAPI
You can create your Vapor web service using any IDE, but we are familiar with using XCode, so let's use that. Vapor has support for creating an XCode project containing our Vapor code, so let's use that:
vapor xcode
Answer y to the prompt to open the XCode project, and you'll be presented with an XCode project with two schemes: a framework scheme with the name of your project, and a Run scheme. Start the Run scheme; this will build your project and launch a local webserver, which will handle requests to http://0.0.0.0:8080.
Enter http://0.0.0.0:8080/plaintext in a browser, and you will see this webpage:

It works! You now have you bare bones Vapor project up and running.