Slide 1

Slide 1 text

ɹ2017/02/08 Kyobashi.swift x AKIBA.swift ߹ಉษڧձ Migrating to Swift 3

Slide 2

Slide 2 text

About Me

Slide 3

Slide 3 text

• ాத ޹໌ (Takaaki Tanaka) • Ϋϥεϝιουגࣜձࣾ • iOS ΞϓϦέʔγϣϯΤϯδχΞ • @kongmingtrap • iOS Developer (Swift / Objective-C) • GyazSquare / GitHub

Slide 4

Slide 4 text

ͱ͋ΔΞϓϦͷ Swift 3ରԠ

Slide 5

Slide 5 text

ͱ͋ΔΞϓϦ • Swift 1.1ͷࠒ͔Β࡞ΒΕ͍ͯΔΞϓϦ • ॳظόʔδϣϯ͸iOS 7ରԠ • Swift 1.2 → 2.1ʹରԠ • ιʔείʔυɹ໿250ϑΝΠϧ • ϥΠϒϥϦ؅ཧ͸CocoaPods

Slide 6

Slide 6 text

ϛογϣϯ iOS 10 ʹ ରԠηϤ

Slide 7

Slide 7 text

iOS 10 • Xcode ͷόʔδϣϯ͸8Ҏ্ • iOS SDK 10Λ૊ΈࠐΉͨΊʹ͸ Swift 2.3ɺ Swift 3.0ରԠ͕ඞཁ

Slide 8

Slide 8 text

Swift 3.0 • NS Prefix͔Βͷ୤٫ • ৽ͨͳΔAPIσβΠϯΨΠυϥΠϯ

Slide 9

Slide 9 text

Swift 3.0 • NS Prefix͔Βͷ୤٫ → Ұ෦࢒Γ·ͨ͠ ʢNSNumberʣ • ৽ͨͳΔAPIσβΠϯΨΠυϥΠϯ → طଘ ͷϥΠϒϥϦͷϝιου໊มΘΓ͗͢ • ABI҆ఆԽ → Swift 4·Ͱ଴ͬͯͶ

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

ʊਓਓਓਓਓਓਓਓਓʊ ʼɹࢼ͞ΕΔ஧੣৺ɹʻ ʉ:?:?:?:?:?:?:?:ʉ

Slide 13

Slide 13 text

Swift 2.3 • Xcode 8 + iOS 10 SDKͰϏϧυ͕Մೳ • Swift 2.x ܥͷAPIσβΠϯ • ͱΓ͋͑ͣٸ͍ͰiOS 10ͰϏϧυ͠ͳ͚Ε ͹ͳΒͳ͍࣌ʹରԠ

Slide 14

Slide 14 text

Swift 2.3 9DPEF3FMFBTF/PUFT • Xcode 8.2 ͕࠷ޙͷαϙʔτʹͳΔͨΊɺ Swift 3.0΁ͷରԠ͸ඞਢ

Slide 15

Slide 15 text

Swift 3.0΁Ҡߦ

Slide 16

Slide 16 text

Swift 2.2΁ͷҠߦ • Xcode 7.2 + Swift 2.1 ͷ։ൃ؀ڥΛXcode 8.2 Ͱىಈͨ͠ࡍɺʮEdit > Convert > To Current Swift Syntax.ʯͷର৅ʹTarget͕දࣔ ͞Εͳ͔ͬͨ • ͱΓ͋͑ͣɺXcode 7.3ͰSwift 2.1͔ΒSwift 2.2΁Ҡߦͨ͠

Slide 17

Slide 17 text

Migration • Xcode 8.2Ͱىಈͨ͠ࡍɺաڈͷSwift όʔ δϣϯͷ৔߹͸Convertը໘͕ىಈ͢Δ • ʮEdit > Convert > To Current Swift Syntax.ʯ Ͱ΋࣮ߦՄೳ • Swift 1.1 → Swift 2.1ͷ࣌͸࢖͍ͷʹͳΒͳ ͔ͬͨ

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

ʊਓਓਓਓਓਓਓਓਓʊ ʼɹ$POWFSU'BJMFEɹʻ ʉ:?:?:?:?:?:?:?:?:?ʉ

Slide 21

Slide 21 text

Migration • Xcode 8.2Ͱىಈͨ͠ࡍɺաڈͷSwift όʔδϣ ϯͷ৔߹͸Convertը໘͕ىಈ͢Δ • ʮEdit > Convert > To Current Swift Syntax.ʯͰ ΋࣮ߦՄೳ • Swift 1.1 → Swift 2.1ͷ࣌͸࢖͍΋ͷʹͳΒͳ ͔ͬͨ • Swift 2.2 → Swift 3.0ͷ࣌΋࢖͍΋ͷʹͳΒͳ ͔ͬͨ ← New!

Slide 22

Slide 22 text

ͦΕͰ΋ແ͍ΑΓ͸Ϛγ • UIKitͷmethodͷม׵ • Enumͷupper case → lower caseม׵ • NSPrefixͷϥΠϒϥϦͷม׵

Slide 23

Slide 23 text

ͻͨ͢Β஍ಓͳ࡞ۀ • CurryԽͨ͠ϝιουͷमਖ਼ public static func log(level level: Level)(@autoclosure name: () -> String) (@autoclosure message: () -> String) -> String { if level.rawValue <= Logger.currentLevel.rawValue { let full = "\(level.description): \(name()) - \(message())" print(full) return full } return "" }

Slide 24

Slide 24 text

ͻͨ͢Β஍ಓͳ࡞ۀ • CurryԽͨ͠ϝιουͷमਖ਼ public static func log(level: Level) -> ((@escaping () -> String) -> ((@escaping () -> String) -> String)) { return { (name: @escaping (() -> String)) in return { (message: @escaping (() -> String)) in if level.rawValue <= Logger.currentLevel.rawValue { let full = "\(level.description): \(name())) - \(message())" print(full) return full } return "" } } }

Slide 25

Slide 25 text

ͻͨ͢Β஍ಓͳ࡞ۀ • closureʹ@escapingͷ௥Ճ

Slide 26

Slide 26 text

ͻͨ͢Β஍ಓͳ࡞ۀ • Ҡߦπʔϧ͕ม׵ͨ͠Օॴͷमਖ਼ Date as NSDate as Date String as NSString as String

Slide 27

Slide 27 text

ͻͨ͢Β஍ಓͳ࡞ۀ • Testͷमਖ਼

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Recap

Slide 30

Slide 30 text

w Ͱ͖Ε͹ೋ౓ͱ΍Γͨ͘ͳ͍ w ίϯϑϦΫτղফͷͨΊɺݽಠͳ࡞ۀ ͱͳΔ w ஧੣৺Λࢼ͞ΕΔ Recap

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

͋Γ͕ͱ͏͍͟͝·ͨ͠