swift at linkedin

43
@ Kamilah Taylor (@kamilah) Kyle Sherman (@drumnkyle)

Upload: kyle-sherman

Post on 14-Apr-2017

3.127 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Swift at LinkedIn

@Kamilah Taylor (@kamilah)

Kyle Sherman (@drumnkyle)

Page 2: Swift at LinkedIn

2 Perspectives

• Kyle represents SlideShare app

• 4 devs, ~3 months for v1

• Kamilah represents Voyager

• Recently released LinkedIn app rewrite

• ~50 devs, ~1 year for v1

Page 3: Swift at LinkedIn

Why Swift?

Page 4: Swift at LinkedIn
Page 5: Swift at LinkedIn

SlideShare

Page 6: Swift at LinkedIn

SlideShare• Timing was right; had just started development

• Interoperability with ObjC

• Most of team coming from Ruby

• Safety Features

https://engineering.linkedin.com/ios/our-swift-experience-slideshare

Page 7: Swift at LinkedIn

LinkedIn Flagship App

Page 8: Swift at LinkedIn

LinkedIn Flagship App

• Immediately started learning Swift

• Tested Swift for new iOS features on current app

• Today widget

• Share extension

Page 9: Swift at LinkedIn

Project Voyager

Page 10: Swift at LinkedIn

Project Voyager

• Engineering discussions for app just started

• Another complete rewrite wouldn’t happen soon

• Concerned with potential pain of switching to Swift later

• Engineers were excited about language features of Swift like optionals

Page 11: Swift at LinkedIn

Growing Pains

Page 12: Swift at LinkedIn

Early Days (Betas)

Page 13: Swift at LinkedIn

Slow compilerSlideShare: 275 Swift files

Page 14: Swift at LinkedIn

Early Days (Betas)

• Syntax Highlighting and Autocomplete slow

• Select few classes had to be ObjC (IB support)

Page 15: Swift at LinkedIn

Abundant SourceKit Crashes

Page 16: Swift at LinkedIn

No migration tool for language changes

Page 17: Swift at LinkedIn

Later Days (Voyager)

Page 18: Swift at LinkedIn

Slow compiler (still a problem)Voyager: 2,748 Swift files

Page 19: Swift at LinkedIn

Xcode

• Compile times very very very long for large codebase (~25 min on 15” rMBP)

• Migration tool crashed on large codebase

• App binary size was large and load time had increased

Page 20: Swift at LinkedIn

Workarounds (Voyager)

• Code structure

• Dropped iOS 7 support

• Modularized using Cocoapod's devpods

• This broke debug symbols

• Converted devpods into dynamic frameworks

Page 21: Swift at LinkedIn

Workarounds (Voyager)• Lengthy, manual migration to new Swift version

• Xcode 7.0 decreased build times dramatically (+26% speed boost)

• Switched generated models to ObjC (to reduce the number of Swift files)

• Mac Pros for everyone! (12 cores gave us a 2x speed boost over the top of the line MBP)

Page 22: Swift at LinkedIn

Workarounds (Voyager)

• Xcode 7 reduced app binary size by 15%

• Increased cold launch time in iOS 9 due to Apple bug that lead to increase in time to load libraries (especially enterprise builds)

• Converted some dynamic libraries to static

Page 23: Swift at LinkedIn

The Pros

Page 24: Swift at LinkedIn

SlideShare

• Syntax way cleaner and easy for newcomers

• Optionals, initialization rules, static typing, etc. much safer

• Less crashes by using optionals and asserting instead of crashing

Page 25: Swift at LinkedIn

Voyager• Whole classes of bugs disappeared (i.e. NPE)...as

long as you never force unwrap optionals!

• Caveat - ObjC libraries that have not been annotated for Swift

Page 26: Swift at LinkedIn

Voyager• Swift lint

• Easier to onboard devs from web or Java

• Especially noticeable with how fast it was for interns to learn Swift

• Community is very active and helpful

• Functional programming

Page 27: Swift at LinkedIn

Libraries

Page 28: Swift at LinkedIn

SlideShare

• We have not integrated any Swift libraries

• Upgrading causes some problems with internal code because of our Today extension

Page 29: Swift at LinkedIn

Voyager

• Most internal libraries are still written in ObjC

• We have some internal and external libraries, written in Swift, integrated

• Cocoapods is how we do all dependency management

Page 30: Swift at LinkedIn

Key Takeaways for teamsFor large teams (and apps), modularize from the

beginning

Page 31: Swift at LinkedIn

Key Takeaways for teams

• It will be faster for you to train new devs on Swift

• Less newbie ObjC errors

Page 32: Swift at LinkedIn

Key Takeaways for teams

• ObjC is still a valid option and will have less issues

• There are still Swift bugs that will cause crashes in your app

• You won't spend time on workarounds for the language and the tools with ObjC

Page 33: Swift at LinkedIn

Key Takeaways for teams

• Managing Xcode version still a pain

• For example, bugs in iOS 8.1, Xcode 6.1, Swift 1.2, etc

• It took months to upgrade to Xcode 7.2

Page 34: Swift at LinkedIn

Great Time to Start!

• Xcode 7 and Swift 2 are much more stable

• Build times are significantly improved

https://github.com/SlideShareInc/swift-style-guide/

Page 35: Swift at LinkedIn

...One More Reason

Swift is now open-source!

Page 36: Swift at LinkedIn

So finally to the question everyone has…

Page 37: Swift at LinkedIn

Should I Use Swift?

Page 38: Swift at LinkedIn

For small teams; brand new app

YES

Page 39: Swift at LinkedIn

For small teams; existing ObjC code

YES, but…

Page 40: Swift at LinkedIn

If You Have an ObjC App

• Code new features in Swift; get familiar with it

• Go back and refactor ObjC where you would see a benefit

• Don’t recommend rewriting entire app unless planning a rewrite for other reasons

Page 41: Swift at LinkedIn

For large teams

Maybe

Page 42: Swift at LinkedIn

Considerations for Swift

• Less time spent on-boarding new developers (much less than ObjC)

• Fewer mistakes made and bugs created (much fewer)

• More workarounds needed for tooling and code (considerable issue for large teams)

Page 43: Swift at LinkedIn

You Decide What’s Right For You!