how we migrated zalando app to swift3?

Post on 13-Apr-2017

49 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Migrating to Swift3@kandelVijaya

Intro to Japanese

• 私の名前はビゼです。

• My name is Bj.

Readability matters.Obj-C [string writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:&error];

<= Swift2.3 "SomeLongText".writeToFile(path, atomically: false, encoding: NSUTF8StringEncoding, error: nil)

Swift3 try! "SomeLongText".write(to: path, atomically: true, encoding: String.Encoding.utf8)

Swift3 try "SomeLongText".write(to: path, atomically: true, encoding: .utf8)

• Change or it will.

• Different point of view makes you analyse options better

Key facts at Zalando• 12 iOS engineers

• 1 repository

• 5 years and counting

• Around 1,00,000 Lines of “OUR” Code

• 51% Swift

• 48% Obj-C

1 Migrator

Thousands of Fixes

Branch

Develop*

Branch

Develop*

swift-3-test

Branch

Develop*

swift-3-test

FFR

• Get more error (~ 170). Fix

• Fix

• Run!

Fixes

• Trivial changes on 95%

• 5% required cognitive effort

Comment

• For non trivial fixes, we placed comments

Branch

Develop*

swift-3-test

30+ FFRDevelop*

swift-3-test

FFR again

Develop* swift-3-test

Features

Develop* swift-3-test

F1 F2

Develop*

swift-3-testF1

F2

Fixing More• Fixing Pods / Dependencies

• Removed TimePiece, Hamcrest

• Migrated ones that didn’t have Swift3 branch yet

• Fixing Unit tests, UI tests

• Make it run!

Do we merge to develop?

• 2 days for entire team to fix the comments

• Do regression test and verify consistency

• Bug bash

Getting back

Develop* swift-3-testF1F2

Feature Progress

Develop* swift-3-testF1

F2

Develop*

swift-3-test

F1

F2

Done!

• But wait!!

How long?

• Almost a month.

• 1 week vacation

Most occurred cases

• [AnyObject: NSObject] —> [AnyHashable: Any]

• Dropping NS prefix

• Annotating closure with @escaping

• Type casting

• Parameter renaming. Not called delegates because of nearly matching signature ie. TableViewDelegate

• Parameter renaming. Not called delegates because of nearly matching signature ie. TableViewDelegate

• many IBAction didn’t work (when manually merging Swift2.3 to swift3). ie. merging later on.

• Private to fileprivate, its everywhere

• public to open everywhere, we didnt wanted it to be that way

New introduction

• fileprivate

• open

• parameter naming

• String! as Optional

Improvements

• Removal of C style for loop

• Removal of ++ and - - operator

• default for closure to @noescape

• More on the change-set

Interesting occurrences

• Method signature nearly matches

• @discardableResult func …. _ = nextResponder.perform(handler, with: actionInfo) _ = navigationController?.popViewController(animated: true)

• 969 warnings. Mostly from unannotated Obj-C API —

• 私の 名前は ビゼ です。

• My name is Bj.

• @kandelvijaya

• AnyQuestions?

top related