38
Building Your App SDK w/ Swift: A Soup to Nuts Guide Jordan Yaker @jordanyaker

Building Your App SDK with Swift

Embed Size (px)

Citation preview

Page 1: Building Your App SDK with Swift

Building Your App SDK w/ Swift:A Soup to Nuts GuideJordan Yaker@jordanyaker

Page 2: Building Your App SDK with Swift

FIS Global

Page 3: Building Your App SDK with Swift

Who is FIS?

•Global Technology Consulting•The best and the brightest.•Emphasis on community.•And more…

Page 4: Building Your App SDK with Swift

Supportify.io

Page 5: Building Your App SDK with Swift

What is Supportify?

“It’s a help-center as as service that allows you to provide your users with instantaneous,

always up-to-date help content. Keep your users happy with less effort using Supportify.”

Page 6: Building Your App SDK with Swift

What is was Supportify?

“It’s a help-center as as service that allows you to provide your users with instantaneous,

always up-to-date help content. Keep your users happy with less effort using Supportify.”

Page 7: Building Your App SDK with Swift

State Of The Product (Spring 2015)•Mature Product•Few Client Libraries•Not Many Customers

Page 8: Building Your App SDK with Swift

Coming Up With A Plan

Page 9: Building Your App SDK with Swift

Libraries Created•.NET Nuget Package•Ruby Gem•PHP Composer Package•WordPress Plugin

Page 10: Building Your App SDK with Swift

Time For iOS•Learn Objective-C• tryobjectivec.codeschool.com• raywenderlich.com/category/ios

•Build Base SDK•???

Page 11: Building Your App SDK with Swift

Get Some Swagger

Page 12: Building Your App SDK with Swift

API Specification Frameworks•RAML• raml.org

•API Blue-Print•apiblueprint.org

•Swagger•swagger.io

•Protocol Buffers•developers.google.com/protocol-buffers

Page 13: Building Your App SDK with Swift

Swagger Project•Swagger Specification (Open API Initiative)•github.com/OAI/OpenAPI-Specification

•Swagger Editor•editor.swagger.io

•Swagger Codegen•github.com/swagger-api/swagger-codegen

Page 14: Building Your App SDK with Swift

Problems With That Swagger•Beware Of Authentication•Early Adopter Woes•Security• Be careful what you share with others.• Exploitation• “…a malicious Swagger definition document…”

Source: https://community.rapid7.com/community/infosec/blog/2016/06/23/r7-2016-06-remote-code-execution-via-swagger-parameter-injection-cve-2016-5641

Page 15: Building Your App SDK with Swift

Stop . . . Demo Time

Page 16: Building Your App SDK with Swift

Supportify Got Swagger (Fall 2015)•.NET Nuget Package•Ruby Gem•PHP Composer Package•Python Package•Java/Android Maven Package•Objective-C CocoaPod

Page 17: Building Your App SDK with Swift

supportify-ios (1.0.0.beta)•Objective-C•AFNetworking•Erased From History•That’s a good thing.

•“Sick code, bro. No really I think it’s contagious. I feel sick just from looking at it.”

Page 18: Building Your App SDK with Swift

Swift: A Modern Language That’s Not Objective-C Code

Page 19: Building Your App SDK with Swift

Time For iOS (Again)•Learn Objective-C•Build Base SDK•Learn Swift•Code School: Swift Live Part 1 / Part 2• raywenderlich.com/category/swift•github.com/raywenderlich/swift-style-guide•developer.apple.com/swift

•Build Base SDK

Page 20: Building Your App SDK with Swift

supportify-ios (1.0.0)

•Swift•AlamoFire•supportify-ios/releases/tag/1.0.0

Image Credit: theoatmeal.com

Page 21: Building Your App SDK with Swift

Why Was The SDK Still Terrible?

“You’re telling me that this is going to save me time, but I have to jump through all of these

hoops to implement it? I’ve already got enough to do on a regular basis. F*ck that. Give me an easy to implement solution that

gives me no aggravation, man.”- Nate Bomberger

Page 22: Building Your App SDK with Swift

iOS Design Patterns

Page 23: Building Your App SDK with Swift

iOS Has Lots Of Design Patterns

Source: medium.com/ios-os-x-development/ios-architecture-patterns-ecba4c38de52

Page 24: Building Your App SDK with Swift

iOS Has Lots Of Design Patterns

Source: medium.com/ios-os-x-development/ios-architecture-patterns-ecba4c38de52

Page 25: Building Your App SDK with Swift

iOS Has Lots Of Design Patterns

Source: medium.com/ios-os-x-development/ios-architecture-patterns-ecba4c38de52

Page 26: Building Your App SDK with Swift

iOS Has Lots Of Design Patterns

Source: medium.com/ios-os-x-development/ios-architecture-patterns-ecba4c38de52

Page 27: Building Your App SDK with Swift

Here Comes A New Challenger:Clean Swift

Page 28: Building Your App SDK with Swift

The Clean Swift Design Pattern

Source: clean-swift.com/clean-swift-ios-architecture

•Everything Talks To The “Next” Thing•Configurators Wire Everything Together•Controllers Talk To The Router•Models Transport Data

Page 29: Building Your App SDK with Swift

The Benefits•Reduced Interdependencies•Component Isolation•Fine-Grained Exposure•Greater Testability•Easier Inheritance•Easier Implementation

Page 30: Building Your App SDK with Swift

Oh Look, More Problems

Page 31: Building Your App SDK with Swift

I Got 99 Problems & Swagger Is One•No Passing Of Server Errors•No Parsing Of Server-Returned Error Objects•AlamoFire Demands Data With 200 Status •The API Wasn’t Using 204 Status Codes

Page 32: Building Your App SDK with Swift

The API Needed Some Tweaks•Tag And Category Filtering•CSV (“Tag 1, Tag 2, Tag 3”) •Rudimentary DSL (“Tag 1 AND (Tag 2 OR Tag

3)”)•The “Order” Parameter•…and the server unit tests just weren’t as good we thought.

Page 33: Building Your App SDK with Swift

The Final Product

Page 34: Building Your App SDK with Swift

supportify-ios (3.1.2)

•Swagger-Based Proxy•API Client•Resource Models

•Global Configurator•Authentication•Global Filters

•Scene Components•Help Center• Category List• Entry List• Entry• Search List

•About Us Page•Tooltip•Onboarding/Wizard

Page 35: Building Your App SDK with Swift

supportify-ios (3.1.X)

•More Components•About Us / Single Content Pages•Tooltip / Popups•Onboarding / Wizards

Page 36: Building Your App SDK with Swift

But Wait – We’re Still Not Done

Page 37: Building Your App SDK with Swift

What Makes For Good Docs?•Copy And Paste•Simple To Complex•Good Structure

Page 38: Building Your App SDK with Swift

Questions?