Swift at LinkedIn
-
Upload
kyle-sherman -
Category
Software
-
view
3.127 -
download
0
Transcript of Swift at LinkedIn
![Page 1: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/1.jpg)
@Kamilah Taylor (@kamilah)
Kyle Sherman (@drumnkyle)
![Page 2: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/2.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/3.jpg)
Why Swift?
![Page 4: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/4.jpg)
![Page 5: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/5.jpg)
SlideShare
![Page 6: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/6.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/7.jpg)
LinkedIn Flagship App
![Page 8: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/8.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/9.jpg)
Project Voyager
![Page 10: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/10.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/11.jpg)
Growing Pains
![Page 12: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/12.jpg)
Early Days (Betas)
![Page 13: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/13.jpg)
Slow compilerSlideShare: 275 Swift files
![Page 14: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/14.jpg)
Early Days (Betas)
• Syntax Highlighting and Autocomplete slow
• Select few classes had to be ObjC (IB support)
![Page 15: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/15.jpg)
Abundant SourceKit Crashes
![Page 16: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/16.jpg)
No migration tool for language changes
![Page 17: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/17.jpg)
Later Days (Voyager)
![Page 18: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/18.jpg)
Slow compiler (still a problem)Voyager: 2,748 Swift files
![Page 19: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/19.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/20.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/21.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/22.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/23.jpg)
The Pros
![Page 24: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/24.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/25.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/26.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/27.jpg)
Libraries
![Page 28: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/28.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/29.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/30.jpg)
Key Takeaways for teamsFor large teams (and apps), modularize from the
beginning
![Page 31: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/31.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/32.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/33.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/34.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/35.jpg)
...One More Reason
Swift is now open-source!
![Page 36: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/36.jpg)
So finally to the question everyone has…
![Page 37: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/37.jpg)
Should I Use Swift?
![Page 38: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/38.jpg)
For small teams; brand new app
YES
![Page 39: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/39.jpg)
For small teams; existing ObjC code
YES, but…
![Page 40: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/40.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/41.jpg)
For large teams
Maybe
![Page 42: Swift at LinkedIn](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/42.jpg)
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](https://reader033.fdocuments.us/reader033/viewer/2022052116/5880a7c81a28abf32c8b462d/html5/thumbnails/43.jpg)
You Decide What’s Right For You!