Chiara Chiappini - Swift and the future of iOS app development

49
Swift and the future of iOS Chiara Chiappini @chiarachiappini google.com/+chiarachiappini

Transcript of Chiara Chiappini - Swift and the future of iOS app development

Page 1: Chiara Chiappini - Swift and the future of iOS app development

Swift and the future of iOS

Chiara Chiappini @chiarachiappini

google.com/+chiarachiappini

Page 2: Chiara Chiappini - Swift and the future of iOS app development

Swift

@chiarachiappini

Jun 2014

June 2015

Some point this

year?

Swift announced at WWDC 2014

Swift 2 announced at WWDC 2015

Swift will be open source

Page 4: Chiara Chiappini - Swift and the future of iOS app development

4 key features of Swift

Modern

@chiarachiappini

Page 5: Chiara Chiappini - Swift and the future of iOS app development

4 key features of Swift

ModernEasy

@chiarachiappini

Page 6: Chiara Chiappini - Swift and the future of iOS app development

4 key features of Swift

ModernEasySafe

@chiarachiappini

Page 7: Chiara Chiappini - Swift and the future of iOS app development

4 key features of Swift

ModernEasySafeSmall

@chiarachiappini

Page 9: Chiara Chiappini - Swift and the future of iOS app development

Swift Playground

@chiarachiappini

Page 10: Chiara Chiappini - Swift and the future of iOS app development

Swift and Objective-C Swift let name ="Chiara"

print("Hello \(name)")

Objective-C NSString*str =@"Hello Chiara";

NSLog(@"%@", str)

@chiarachiappini

Page 11: Chiara Chiappini - Swift and the future of iOS app development

Xcode vs Appcode

@chiarachiappini

Page 12: Chiara Chiappini - Swift and the future of iOS app development

Dependency managementCocoapods vs Maven vs Gradle

@chiarachiappini

Page 13: Chiara Chiappini - Swift and the future of iOS app development

sudo gem install cocoapodspod init

edit PodFile (similar to editing pom.xml)pod install

@chiarachiappini

Page 14: Chiara Chiappini - Swift and the future of iOS app development

platform :ios, '8.0'use_frameworks!

target 'SwiftTalk' do pod 'Alamofire', '~> 3.1'end

target 'SwiftTalkTests' do pod 'Quick', '~> 0.6.0' pod 'Nimble', '2.0.0-rc.3'end

Page 15: Chiara Chiappini - Swift and the future of iOS app development

Protocol vs Interface

@chiarachiappini

Page 16: Chiara Chiappini - Swift and the future of iOS app development

protocol Sweet { var sugarQuantity: Int { get }}

class BlackChocolate: Sweet { var sugarQuantity: Int = 10}

@chiarachiappini

Page 17: Chiara Chiappini - Swift and the future of iOS app development

Unit Tests

@chiarachiappini

Page 18: Chiara Chiappini - Swift and the future of iOS app development

XCTest vs JUnit

testing framework integrated with XCode

@chiarachiappini

Page 19: Chiara Chiappini - Swift and the future of iOS app development

XCTest exampleclass MyTestsXCTests: XCTestCase{ let myNumbers = [1,2,3] func testNumbersWithXCTest() { XCTAssertEqual(1 + 1, 2, "expected one plus one to equal two") for number in myNumbers{ XCTAssertLessThan(number, 4) } }}

@chiarachiappini

Page 20: Chiara Chiappini - Swift and the future of iOS app development

Use @testableimport XCTest@testable import CodemotionExamples

class CodemotionExamplesTests: XCTestCase { func testBlackChocolateHasSugar() { let blackChocolate = BlackChocolate() XCTAssertEqual(blackChocolate.sugarQuantity, 10, "Expected sugar quantity is 10") } }

@chiarachiappini

Page 21: Chiara Chiappini - Swift and the future of iOS app development

Quick and Nimble

Quick:behaviour driven testing frameworkNimble: fluent assertions

https://github.com/Quick/Nimble

@chiarachiappini

Page 22: Chiara Chiappini - Swift and the future of iOS app development

Nimble

func testNumbersWithNimble() { expect(1+1).to(equal(2)) expect([1,2,3]).to(allPass(beLessThan(4))) }

@chiarachiappini

Page 23: Chiara Chiappini - Swift and the future of iOS app development

func testStringWithNimble() { let myString = "Hello!" expect(myString).to(equal("Hello!"))

expect(myString)==("Hello!") expect(myString).to(beginWith("Hel")) }

@chiarachiappini

Page 24: Chiara Chiappini - Swift and the future of iOS app development

Quickclass MyTestsQuick: QuickSpec { override func spec() { describe("Testing numbers") { context("when adding 1 and 2"){ it("results as 3") { expect(1+2).to(equal(3)) } } }

@chiarachiappini

Page 25: Chiara Chiappini - Swift and the future of iOS app development

Testing and CI

@chiarachiappini

Page 26: Chiara Chiappini - Swift and the future of iOS app development

Continuous Integration

early feedback

@chiarachiappini

Page 27: Chiara Chiappini - Swift and the future of iOS app development

Continuous Integration

early feedbackteam peace of mind and alerting

@chiarachiappini

Page 28: Chiara Chiappini - Swift and the future of iOS app development

Continuous Integration

early feedbackteam peace of mind and alerting

standardized build

@chiarachiappini

Page 29: Chiara Chiappini - Swift and the future of iOS app development

Continuous Integration

early feedbackteam peace of mind and alerting

standardized buildrecord of results

@chiarachiappini

Page 30: Chiara Chiappini - Swift and the future of iOS app development

Continuous Integration

early feedbackteam peace of mind and alerting

standardized buildrecord of results

support release process

@chiarachiappini

Page 31: Chiara Chiappini - Swift and the future of iOS app development

Continuous Integration

early feedbackteam peace of mind and alerting

standardized buildrecord of results

support release processfirst step to continuous deployment

@chiarachiappini

Page 32: Chiara Chiappini - Swift and the future of iOS app development

CI for mobile

maturityemulators and real devices

@chiarachiappini

Page 33: Chiara Chiappini - Swift and the future of iOS app development

CI for iOS

Xcode server

@chiarachiappini

Page 34: Chiara Chiappini - Swift and the future of iOS app development

CI for iOS

Xcode serverJenkins

@chiarachiappini

Page 35: Chiara Chiappini - Swift and the future of iOS app development

CI for iOS

Xcode serverJenkins

...

@chiarachiappini

Page 36: Chiara Chiappini - Swift and the future of iOS app development

Xcode service and bots

Xcode service integrated in Xcode

@chiarachiappini

Page 37: Chiara Chiappini - Swift and the future of iOS app development

Xcode service and bots

Xcode service integrated in Xcodemanage bots from Xcode

@chiarachiappini

Page 38: Chiara Chiappini - Swift and the future of iOS app development

Jenkins

Xcode plugin or Xcode tool

@chiarachiappini

Page 39: Chiara Chiappini - Swift and the future of iOS app development

Jenkins Jobs

build and unit test the app

@chiarachiappini

Page 40: Chiara Chiappini - Swift and the future of iOS app development

Jenkins Jobs

build and unit test the apprun functional tests

@chiarachiappini

Page 41: Chiara Chiappini - Swift and the future of iOS app development

Jenkins Jobs

build and unit test the apprun acceptance tests

build application archive (ipa)

@chiarachiappini

Page 42: Chiara Chiappini - Swift and the future of iOS app development

Jenkins Jobs

build and unit test the apprun acceptance tests

build application archive (ipa)tag and archive the ipa

@chiarachiappini

Page 43: Chiara Chiappini - Swift and the future of iOS app development

Jenkins Jobs

build and unit test the apprun acceptance tests

build application archive (ipa)tag and archive the ipa

send to TestFlight@chiarachiappini

Page 44: Chiara Chiappini - Swift and the future of iOS app development

What we learntWhat is Swift

Page 45: Chiara Chiappini - Swift and the future of iOS app development

What we learntWhat is Swift

How to practice

Page 46: Chiara Chiappini - Swift and the future of iOS app development

What we learntWhat is Swift

How to practice Some Java-Swift language equivalences

Page 47: Chiara Chiappini - Swift and the future of iOS app development

What we learntWhat is Swift

How to practice Some Java-Swift language equivalences

Tools

Page 48: Chiara Chiappini - Swift and the future of iOS app development

What we learntWhat is Swift

How to practice Some Java-Swift language equivalences

ToolsTesting and CI

Page 49: Chiara Chiappini - Swift and the future of iOS app development

Go for Swift!