Tatsuya server side cover

Server-Side Swift Live Coding

Introduction

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

Demonstration

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.

Next Up: Super Spectacular Server-Side Swift!

General link arrow white

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.

Tatsuya Tobioka

Tatsuya is a Swift developer from Japan. He maintains his portfolio of work at http://tnantoka.com.

4 design patterns for a RESTless mobile integration »

close