Server-Side Swift in Action!
-
Upload
pablo-villar -
Category
Software
-
view
63 -
download
0
Transcript of Server-Side Swift in Action!
www.erlang-solutions.com
DECEMBER 1st, 2016@ Inaka's Offices
SWIFTBA MEETUP
www.erlang-solutions.com
HELLO!
Pablo Villar @volbap
_iOS dev since 2011
_swifter since 2015
_swiftBA co-organizer
www.erlang-solutions.com
ServerSideSwift
In Action!
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
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
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
www.erlang-solutions.com
Why using Swift on server-side?
● Watch this talk:
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/
www.erlang-solutions.com
Why using Swift on server-side?
www.erlang-solutions.com
Why using Swift on server-side?
www.erlang-solutions.com
Why using Swift on server-side?
www.erlang-solutions.com
Why using Swift on server-side?
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!
www.erlang-solutions.com
First thing you notice...
● WHERE IS MY XCODE??
www.erlang-solutions.com
Second thing you notice
● I knew you'll miss me one day...
(BTW: http://www.textfromxcode.com/ for fun!)
www.erlang-solutions.com
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
www.erlang-solutions.com
But be aware!
● Here are some gotchas:
○
www.erlang-solutions.com
But be aware!
● Here are some gotchas:
www.erlang-solutions.com
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)
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
www.erlang-solutions.com
What now?
● Can't we turn this into something more interesting?
www.erlang-solutions.com
Meet Jolly
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…)
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
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
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
www.erlang-solutions.com
THANK YOU!
@volbap