Upgrade to Pro — share decks privately, control downloads, hide ads and more …

今なら言える、 クラスメソッドとSwiftの歴史 〜開発現場の光と闇〜

今なら言える、 クラスメソッドとSwiftの歴史 〜開発現場の光と闇〜

大阪オフィス開設1周年勉強会の資料です

http://dev.classmethod.jp/news/mobileteam-inosaka-vol-3/

Takaaki Tanaka

April 28, 2017
Tweet

More Decks by Takaaki Tanaka

Other Decks in Technology

Transcript

  1. • ాத ޹໌ (Takaaki Tanaka) • Ϋϥεϝιουגࣜձࣾ • ϞόΠϧόοΫΤϯυ •

    @kongmingtrap • Swift / Objective-C / Scala / JavaScript … • GyazSquare / GitHub
  2. Agenda •Contact with Architecture •Battle with Swift version •Delivery is

    first priority •Battle with Swift version, second
  3. Agenda •Contact with Architecture •Battle with Swift version •Delivery is

    first priority •Battle with Swift version, second
  4. • CargoBay • CorePlot • MBProgressHUD • UICKeyChainStore • JASidePanels

    • MagicalRecord • BlocksKit/UIKit • BlocksKit/MessageUI • Alamofire • SwiftyJSON • BrightFutures • OHHTTPStubs • Quick • Nimble
  5. • CargoBay • CorePlot • MBProgressHUD • UICKeyChainStore • JASidePanels

    • MagicalRecord • BlocksKit/UIKit • BlocksKit/MessageUI • Alamofire • SwiftyJSON • BrightFutures • OHHTTPStubs • Quick • Nimble
  6. Future / Promise Future ͸ฒྻʹ࣮ߦ͞ΕΔෳ਺ͷԋࢉΛऔΓѻ͏ͷʹศརͳ ํ๏Λఏڙ͢ΔɻͦΕ͸ޮ཰తͰϊϯϒϩοΩϯάͳํ๏ͩɻ େ·͔ͳߟ͑ํ͸γϯϓϧͳ΋ͷͰɺFuture ͸·ͩଘࡏ͠ͳ͍ ܭࢉ݁Ռʹର͢ΔϓϨʔεϗϧμͷΑ͏ͳ΋ͷͩɻ Ұൠత

    ʹɺFuture ͷ݁Ռ͸ฒߦʹܭࢉ͞ΕޙͰूܭ͢Δ͜ͱ͕Ͱ͖ Δɻ ͜ͷΑ͏ʹฒߦͳλεΫΛ߹੒͢Δ͜ͱͰɺΑΓ଎͘ɺ ඇಉظͰɺϊϯϒϩοΩϯάͳฒྻίʔυͱͳΔ͜ͱ͕ଟ͍ɻ http://docs.scala-lang.org/ja/overviews/core/futures.html
  7. open func postWaveformWithLead( _ lead: Lead, subjectiveSymptoms: [Checkup.SubjectiveSymptom]?, createDate: Date,

    saving: Bool, waveformData: Data) -> Future<Checkup, NSError> { let waveformUUID = UUID().uuidString return createLocalWaveformWithUuid( waveformUUID, lead: lead, subjectiveSymptoms: subjectiveSymptoms, createDate: createDate, waveformData: waveformData) .flatMap { [weak self] _ -> Future<JSON, NSError> in self?.uploadWaveformDatumWithLead( lead, subjectiveSymptoms: subjectiveSymptoms, createDate: createDate, saving: saving, waveformData: waveformData ) ?? Future(error: InteractorCancelError) } .flatMap { [weak self] json -> Future<Checkup, NSError> in self?.executeTaskAfterUploadWithJson(json, uuid: waveformUUID) ?? Future(error: InteractorCancelError) } }
  8. open func postWaveformWithLead( _ lead: Lead, subjectiveSymptoms: [Checkup.SubjectiveSymptom]?, createDate: Date,

    saving: Bool, waveformData: Data) -> Future<Checkup, NSError> { let waveformUUID = UUID().uuidString return createLocalWaveformWithUuid( waveformUUID, lead: lead, subjectiveSymptoms: subjectiveSymptoms, createDate: createDate, waveformData: waveformData) .flatMap { [weak self] _ -> Future<JSON, NSError> in self?.uploadWaveformDatumWithLead( lead, subjectiveSymptoms: subjectiveSymptoms, createDate: createDate, saving: saving, waveformData: waveformData ) ?? Future(error: InteractorCancelError) } .flatMap { [weak self] json -> Future<Checkup, NSError> in self?.executeTaskAfterUploadWithJson(json, uuid: waveformUUID) ?? Future(error: InteractorCancelError) } }
  9. open func postWaveformWithLead( _ lead: Lead, subjectiveSymptoms: [Checkup.SubjectiveSymptom]?, createDate: Date,

    saving: Bool, waveformData: Data) -> Future<Checkup, NSError> { let waveformUUID = UUID().uuidString return createLocalWaveformWithUuid( waveformUUID, lead: lead, subjectiveSymptoms: subjectiveSymptoms, createDate: createDate, waveformData: waveformData) .flatMap { [weak self] _ -> Future<JSON, NSError> in self?.uploadWaveformDatumWithLead( lead, subjectiveSymptoms: subjectiveSymptoms, createDate: createDate, saving: saving, waveformData: waveformData ) ?? Future(error: InteractorCancelError) } .flatMap { [weak self] json -> Future<Checkup, NSError> in self?.executeTaskAfterUploadWithJson(json, uuid: waveformUUID) ?? Future(error: InteractorCancelError) } }
  10. open func postWaveformWithLead( _ lead: Lead, subjectiveSymptoms: [Checkup.SubjectiveSymptom]?, createDate: Date,

    saving: Bool, waveformData: Data) -> Future<Checkup, NSError> { let waveformUUID = UUID().uuidString return createLocalWaveformWithUuid( waveformUUID, lead: lead, subjectiveSymptoms: subjectiveSymptoms, createDate: createDate, waveformData: waveformData) .flatMap { [weak self] _ -> Future<JSON, NSError> in self?.uploadWaveformDatumWithLead( lead, subjectiveSymptoms: subjectiveSymptoms, createDate: createDate, saving: saving, waveformData: waveformData ) ?? Future(error: InteractorCancelError) } .flatMap { [weak self] json -> Future<Checkup, NSError> in self?.executeTaskAfterUploadWithJson(json, uuid: waveformUUID) ?? Future(error: InteractorCancelError) } }
  11. Swift 2.1 • Xcode 7 + iOS 9 SDKͰϏϧυ͕Մೳ •

    Swift 2.x ܥͷAPIσβΠϯ • try / catch͕௥Ճ • Ұ෦ͷϓϩύςΟ͕Optionalʹͳͬͨ(SDK) • Dynamic LibraryରԠ(Xcode 7)
  12. Migration • Xcode 7.1Ͱىಈͨ͠ࡍɺաڈͷSwift όʔ δϣϯͷ৔߹͸Convertը໘͕ىಈ͢Δ • ʮEdit > Convert

    > To Current Swift Syntax.ʯ Ͱ΋࣮ߦՄೳ • Swift 1.2 → Swift 2.1ͷ࣌͸࢖͍΋ͷʹͳΒ ͳ͔ͬͨ ← New!
  13. Swift 3.0 • NS Prefix͔Βͷ୤٫ → Ұ෦࢒Γ·ͨ͠ ʢNSNumberʣ • ৽ͨͳΔAPIσβΠϯΨΠυϥΠϯ

    → طଘ ͷϥΠϒϥϦͷϝιου໊มΘΓ͗͢ • ABI҆ఆԽ → Swift 4·Ͱ଴ͬͯͶ
  14. Swift 2.3 • Xcode 8 + iOS 10 SDKͰϏϧυ͕Մೳ •

    Swift 2.x ܥͷAPIσβΠϯ • ͱΓ͋͑ͣٸ͍ͰiOS 10ͰϏϧυ͢Δඞཁ ͕͋Δ৔߹
  15. 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΁Ҡߦͨ͠
  16. Migration • Xcode 8.2Ͱىಈͨ͠ࡍɺաڈͷSwift όʔδϣ ϯͷ৔߹͸Convertը໘͕ىಈ͢Δ • ʮEdit > Convert

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

    > To Current Swift Syntax.ʯͰ΋ ࣮ߦՄೳ • Swift 1.2 → Swift 2.1ͷ࣌͸࢖͍΋ͷʹͳΒͳ ͔ͬͨ • Swift 2.2 → Swift 3.0ͷ࣌΋࢖͍΋ͷʹͳΒͳ ͔ͬͨ ← New!
  18. ͻͨ͢Β஍ಓͳ࡞ۀ • 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 "" }
  19. ͻͨ͢Β஍ಓͳ࡞ۀ • 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 "" } } }
  20. AWSࣄۀ෦ AWSΤϯδχΞʢAWSγεςϜ؀ڥͷߏஙࢧԉʣ AWSιϦϡʔγϣϯΞʔΩςΫτʢAWSγεςϜ؀ڥ ίϯαϧɾߏஙɾӡ༻ࢧԉʣ AWSΦϖϨʔγϣϯίϯαϧλϯτʢAWSγεςϜ؀ڥͷӡ༻ࣗಈԽࢧԉʣ AWSαʔϏεσϕϩούʔʢAWSΛ׆༻ͨ͠αʔϏε։ൃʣ
 ϞόΠϧΞϓϦαʔϏε෦ iOS / AndroidΞϓϦ։ൃΤϯδχΞ

    ― ౦ژ / ࡳຈ / େࡕ ϞόΠϧόοΫΤϯυΤϯδχΞ ― ౦ژ / ࡳຈ / େࡕ DevOpsΤϯδχΞ ― ౦ژ / ࡳຈ / େࡕ ϓϩδΣΫτϚωʔδϟʔʢϞόΠϧΞϓϦʣ ― ౦ژ / େࡕ ݱࡏืूதͷ৬छ https://classmethod.jp/recruit/jobs/