NSDateformatter.com is a website where you can experiment with
NSDateFormatter live. Here, I’ll create a website where you can experiment with server-side Swift live.
Sites I’ve created that allowed live experimentation included:
Get more development news like this
There are many server-side frameworks written in Swift. For this demonstration, I will use Vapor. I will use Xcode to write the app, mainly for its auto-completion, and I will run it on Docker.
We’ll make a simple app that shows a live demonstration of the string upper case method using a template from Vapor (see the video for the source code). We create the root GET request, handle the input JSON, and then the POST request. Lastly, we write a test converting the input to and uppercase string; this will be our template.
Creating the Actual App
First, we create a project from the template, and open it in Xcode. We edit the PackageDescription file, by adding the dependencies, which can be seen here: https://github.com/IBM-Swift/Kitura-markdown.git.
In the Example Model, when we import the KituraMarkdown file, the output will be
KituraMarkdown.render(from: input). Then, we can write the tests to verify that the live changes are correct.
About the content
This talk was delivered live in March 2017 at try! Swift Tokyo. The video was recorded, produced, and transcribed by Realm, and is published here with the permission of the conference organizers.