29
www.erlang-solutions.com DECEMBER 1st, 2016 @ Inaka's Offices SWIFTBA MEETUP

Server-Side Swift in Action!

Embed Size (px)

Citation preview

Page 1: Server-Side Swift in Action!

www.erlang-solutions.com

DECEMBER 1st, 2016@ Inaka's Offices

SWIFTBA MEETUP

Page 2: Server-Side Swift in Action!

www.erlang-solutions.com

HELLO!

Pablo Villar @volbap

_iOS dev since 2011

_swifter since 2015

[email protected]

_swiftBA co-organizer

Page 3: Server-Side Swift in Action!

www.erlang-solutions.com

ServerSideSwift

In Action!

Page 4: Server-Side Swift 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

Page 7: Server-Side Swift in Action!

www.erlang-solutions.com

Why using Swift on server-side?

● Watch this talk:

Page 9: Server-Side Swift in Action!

www.erlang-solutions.com

Why using Swift on server-side?

Page 10: Server-Side Swift in Action!

www.erlang-solutions.com

Why using Swift on server-side?

Page 11: Server-Side Swift in Action!

www.erlang-solutions.com

Why using Swift on server-side?

Page 12: Server-Side Swift in Action!

www.erlang-solutions.com

Why using Swift on server-side?

Page 13: Server-Side Swift in Action!

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!

www.erlang-solutions.com

First thing you notice...

● WHERE IS MY XCODE??

Page 15: Server-Side Swift in Action!

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!

www.erlang-solutions.com

Page 17: Server-Side Swift in Action!

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!

www.erlang-solutions.com

But be aware!

● Here are some gotchas:

Page 19: Server-Side Swift in Action!

www.erlang-solutions.com

But be aware!

● Here are some gotchas:

Page 20: Server-Side Swift in Action!

www.erlang-solutions.com

Page 21: Server-Side Swift in Action!

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!

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!

www.erlang-solutions.com

What now?

● Can't we turn this into something more interesting?

Page 24: Server-Side Swift in Action!

www.erlang-solutions.com

Meet Jolly

Page 25: Server-Side Swift in Action!

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!

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!

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!

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!

www.erlang-solutions.com

THANK YOU!

Any [email protected]

@volbap