server-side swift in action!
TRANSCRIPT
![Page 1: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/1.jpg)
www.erlang-solutions.com
DECEMBER 1st, 2016@ Inaka's Offices
SWIFTBA MEETUP
![Page 2: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/2.jpg)
www.erlang-solutions.com
HELLO!
Pablo Villar @volbap
_iOS dev since 2011
_swifter since 2015
_swiftBA co-organizer
![Page 3: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/3.jpg)
www.erlang-solutions.com
ServerSideSwift
In Action!
![Page 4: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/4.jpg)
www.erlang-solutions.com
Where do we start?
● First, you need a framework in order to have server-side support…○ (Unless you're so hardcore to DIY)
● There are several:○ Kitura (IBM)○ Perfect○ Vapor○ Zewo○ And more...
Case study
![Page 5: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/5.jpg)
www.erlang-solutions.com
Which one is better?
https://medium.com/@rymcol/benchmarks-for-the-top-server-side-swift-frameworks-vs-node-js-24460cfe0beb#.mb95hntz6
![Page 6: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/6.jpg)
www.erlang-solutions.com
Which one is better?
https://medium.com/@rymcol/benchmarks-for-the-top-server-side-swift-frameworks-vs-node-js-24460cfe0beb#.mb95hntz6
![Page 7: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/7.jpg)
www.erlang-solutions.com
Why using Swift on server-side?
● Watch this talk:
![Page 8: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/8.jpg)
www.erlang-solutions.com
Why using Swift on server-side?
● VIDEO with slides: https://realm.io/news/tryswift-chris-robert-end-to-end-application-development-swift-backend/
● SLIDES only: http://www.slideshare.net/cnbailey/tryswift-nyc-end-to-end-application-development-in-swift
● https://www.tryswift.co/
![Page 9: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/9.jpg)
www.erlang-solutions.com
Why using Swift on server-side?
![Page 10: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/10.jpg)
www.erlang-solutions.com
Why using Swift on server-side?
![Page 11: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/11.jpg)
www.erlang-solutions.com
Why using Swift on server-side?
![Page 12: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/12.jpg)
www.erlang-solutions.com
Why using Swift on server-side?
![Page 13: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/13.jpg)
www.erlang-solutions.com
Let's DO IT!
● Let's create our first server!
○ http://kitura.io/
○ https://github.com/IBM-Swift/Kitura/
● Reminder for Pablo:
○ Do live coding until we get the server running!
![Page 14: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/14.jpg)
www.erlang-solutions.com
First thing you notice...
● WHERE IS MY XCODE??
![Page 15: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/15.jpg)
www.erlang-solutions.com
Second thing you notice
● I knew you'll miss me one day...
(BTW: http://www.textfromxcode.com/ for fun!)
![Page 16: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/16.jpg)
www.erlang-solutions.com
![Page 17: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/17.jpg)
www.erlang-solutions.com
Everything's Not Lost
● If you miss Xcode, you can still:
○ Open your .swift files with Xcode
● No, really, you can:
○ swift package generate-xcodeproj
![Page 18: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/18.jpg)
www.erlang-solutions.com
But be aware!
● Here are some gotchas:
○
![Page 19: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/19.jpg)
www.erlang-solutions.com
But be aware!
● Here are some gotchas:
![Page 20: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/20.jpg)
www.erlang-solutions.com
![Page 21: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/21.jpg)
www.erlang-solutions.com
Another gotcha
● Console apps do NOT bundle stuff
● Console apps do NOT use NSBundle
● Do not use files from your bundle to
store your configurations…
○ (e.g. a plist)
![Page 22: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/22.jpg)
www.erlang-solutions.com
And so on...
● You will encounter several of these
blockers along the way…
○ Stack Overflow is your friend! :)
○ Google is your BEST friend! :D
![Page 23: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/23.jpg)
www.erlang-solutions.com
What now?
● Can't we turn this into something more interesting?
![Page 24: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/24.jpg)
www.erlang-solutions.com
Meet Jolly
![Page 25: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/25.jpg)
www.erlang-solutions.com
Meet Jolly
● https://github.com/inaka/Jolly
○ Server written in Swift
■ Using Kitura framework
● Therefore Swift Package Manager
■ Unit-tested
■ Running on Linux (well, not really…)
![Page 26: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/26.jpg)
www.erlang-solutions.com
Swift on Linux
● You can run Swift code on Linux:
○ https://ashfurrow.com/blog/swift-on-linux/
● BUT:
○ macOS environments use Foundation
○ Linux environments use SwiftFoundation
![Page 27: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/27.jpg)
www.erlang-solutions.com
Foundation Swift-Foundationhttp://blog.krzyzanowskim.com/2016/03/23/status-of-portable-swift-code/
● Written in Objective-C
● Swift-compatible
● We use it everyday
● Written in Swift
● Not obj-c compatible
● Brand new!
● Still not finished!
import Foundation import Swift
![Page 28: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/28.jpg)
www.erlang-solutions.com
The Last Slide
● Server-side Swift is a reality
● However, it's still on its early stages
● So is Swift Package Manager
● Swift on Linux is too green yet (to me)
● Swift is getting everywhere
![Page 29: Server-Side Swift in Action!](https://reader031.vdocuments.us/reader031/viewer/2022030317/5871236b1a28abe4448b5949/html5/thumbnails/29.jpg)
www.erlang-solutions.com
THANK YOU!
@volbap