There has been a lot of buzz around bringing Swift to the server and use it on the web. Lately the Swift team assigned a work group responsible for the Server APIs Project pushing even further this idea.
The main arguments are that Swift:
- is fast, compared to Ruby for example;
- is a safe language, since it is strongly typed;
- it is more expressive than Java or C#;
We don’t know if these are enough strong or valid motives to reinvent the wheel. For us the main motive as an iOS Developer is to Build end-to-end applications in Swift. Nevertheless we decided to make a spike exploring how it is to develop an API using Swift.
The largest Server Side Swift frameworks are:
After watching Session 415 from WWDC 16, Going Server-side with Swift Open Source, we decided to try Kitura from IBM.
The provided Getting Started is fairly simple to follow, where you end up with a “Hello, World!” that responds on http://localhost:8090
Here is the macOS app with one Server Repository, one Cloud Runtime, and one cliente iOS App.
We use the same workspace for both the Server and iOS application using the following guide.
The sample project we did was very simple, the server expose a route with a static JSON and the application read from it. The nice thing about having the Server code and the iOS application is that you can work on it at the same time and reuse code between them.
The project is available at our GitHub.