SwiftUIを導入したアプリ設計

E387c487b4fea568909cf805f91afe92?s=47 Yu Tawata
September 21, 2020

 SwiftUIを導入したアプリ設計

iOSDC Japan 2020での登壇資料です

E387c487b4fea568909cf805f91afe92?s=128

Yu Tawata

September 21, 2020
Tweet

Transcript

  1. Yu Tawata, 2020/9/21 SwiftUIΛಋೖͨ͠ΞϓϦઃܭ iOSDC Japan 2020

  2. ࣗݾ঺հ • Yu Tawata • iOS Engineer • Twitter: yuta24

    • Joined DMM at 2019
  3. None
  4. ΞδΣϯμ • ઃܭͷ໨ඪ • SwiftUI • ՝୊ • ݕূ •

    ΞʔΩςΫνϟ • ϑϩʔ • ·ͱΊ
  5. ઃܭͷ໨ඪ • ੜ࢈ੑ • Ϗϧυ࣌ؒ • ࣮૷ίετ • UI •

    σΟʔϓϦϯΫ • ςετ༰қੑ • Ϣχοτςετ • εφοϓγϣοτςετ
  6. ઃܭͷ໨ඪ • ੜ࢈ੑ • Ϗϧυ࣌ؒ • ࣮૷ίετ • UI •

    σΟʔϓϦϯΫ • ςετ༰қੑ • Ϣχοτςετ • εφοϓγϣοτςετ ϚϧνϑϨʔϜϫʔΫ SwiftUI Coordinator DI ViewState
  7. None
  8. SwiftUI • ओͳಛ௃ • એݴతʹUIΛهड़Ͱ͖Δ • ࣮ࡍͷΞϓϦΛಈ࡞ͤͯ͞୯ҰViewΛPreviewͰ͖Δ • શͯͷAppleϓϥοτϑΥʔϜ্Ͱར༻Ͱ͖Δ •

    ޓ׵ੑ • SwiftUI্ʹUIKitͷViewΛ௥ՃՄೳ • UIKitͷViewʹSwiftUIͷViewΛ௥ՃՄೳ
  9. બ୒ࢶ 1. SwiftUIΛϕʔεʹ࣮૷͠ɺUIKitΛҰ෦Ͱར༻͢Δ 2. UIKitΛϕʔεʹ࣮૷͠ɺSwiftUIΛҰ෦Ͱར༻͢Δ 3. UIKitͷΈͰ࣮૷͢Δ

  10. બ୒ࢶ 1. SwiftUIΛϕʔεʹ࣮૷͠ɺUIKitΛҰ෦Ͱར༻͢Δ 2. UIKitΛϕʔεʹ࣮૷͠ɺSwiftUIΛҰ෦Ͱར༻͢Δ 3. UIKitͷΈͰ࣮૷͢Δ

  11. ߟྀ͢΂͖ཁ݅ • ػೳ • Χϧʔηϧදࣔ • ෳ਺ͷΞϓϦىಈܦ࿏ • ඇػೳ •

    จࣈ૷০ • ΞφϦςΟΫε • ը໘ભҠ • Ϙλϯλοϓ • ίϯόʔδϣϯ • ΫϥογϡϝτϦΫε • ύϑΥʔϚϯεϞχλϦϯά
  12. • ػೳ • Χϧʔηϧදࣔ • ෳ਺ͷΞϓϦىಈܦ࿏ • ඇػೳ • จࣈ૷০

    • ΞφϦςΟΫε • ը໘ભҠ • Ϙλϯλοϓ • ίϯόʔδϣϯ • ΫϥογϡϝτϦΫε • ύϑΥʔϚϯεϞχλϦϯά ߟྀ͢΂͖ཁ݅
  13. ෳ਺ͷΞϓϦىಈܦ࿏ • UIKitͷ৔߹ • Coordinatorύλʔϯ • SwiftUIͷ৔߹ • ʁʁʁʁ

  14. UIKitͷ৔߹ - Coordinator • ը໘ભҠॲཧΛVC͔Β CoordinatorʹҠৡ͢Δ • VCؒͷґଘΛૄʹ͢ΔσβΠϯ ύλʔϯ

  15. UIKitͷ৔߹ - Coordinator AppCoordinator AuthCoordinator MainCoordinator

  16. UIKitͷ৔߹ - Coordinator AppCoordinator AuthCoordinator MainCoordinator

  17. UIKitͷ৔߹ - Coordinator AppCoordinator AuthCoordinator MainCoordinator

  18. UIKitͷ৔߹ - Coordinator AppCoordinator AuthCoordinator MainCoordinator Coordinator͕ը໘ભҠΛߦ͏

  19. SwiftUIͷ৔߹ -ʁʁʁʁ • ϓογϡ • Ϟʔμϧ

  20. SwiftUIͷ৔߹ -ʁʁʁʁ • ٻΊΒΕΔ࣮૷ • બ୒ͨ͠৘ใΛड౉͠Ͱ͖Δ • ෼ذ৚݅Λ͚ͭΒΕΔ • ਌View͔ΒͷΠϕϯτ఻ୡ

  21. τϥοΩϯάʔը໘ભҠ • UIKitͷ৔߹ • Google Analytics for Firebase • SwiftUIͷ৔߹

    • ʁʁʁʁ
  22. UIKitͷ৔߹ - Google Analytics for Firebase

  23. SwiftUIͷ৔߹ -ʁʁʁʁ

  24. None
  25. UIHostingController UITabBarController UIHostingController UINavigationController DestinationHostingController

  26. UIHostingController UITabBarController UIHostingController UINavigationController DestinationHostingController Analyticsʹ͸͍ͣΕͷViewControllerͷ σʔλ΋ه࿥͞Ε͍ͯͳ͔ͬͨ

  27. SwiftUIͷ৔߹ -ʁʁʁʁ

  28. બ୒ࢶ 1. SwiftUIΛϕʔεʹ࣮૷͠ɺUIKitΛҰ෦Ͱར༻͢Δ 2. UIKitΛϕʔεʹ࣮૷͠ɺSwiftUIΛҰ෦Ͱར༻͢Δ 3. UIKitͷΈͰ࣮૷͢Δ

  29. બ୒ࢶ 1. SwiftUIΛϕʔεʹ࣮૷͠ɺUIKitΛҰ෦Ͱར༻͢Δ 2. UIKitΛϕʔεʹ࣮૷͠ɺSwiftUIΛҰ෦Ͱར༻͢Δ 3. UIKitͷΈͰ࣮૷͢Δ Ͳͷ৔໘Ͱ׆༻Ͱ͖Δʁ

  30. ݕূ 1. UIViewʹSwiftUIΛར༻͢Δ 2. UITableViewʹSwiftUIΛར༻͢Δ 3. UICollectionViewʹSwiftUIΛར༻͢Δ

  31. ݕূ 1. UIViewʹSwiftUIΛར༻͢Δ 2. UITableViewʹSwiftUIΛར༻͢Δ 3. UICollectionViewʹSwiftUIΛར༻͢Δ

  32. UITableViewʹSwiftUIΛར༻͢Δ

  33. None
  34. ݕূ 1. UIViewʹSwiftUIΛར༻͢Δ 2. UITableViewʹSwiftUIΛར༻͢Δ • HostingTableViewCellͰ೚ҙͷSwiftUIͷViewΛදࣔͰ͖Δ • Self-Sizingʹ΋ରԠͰ͖Δ 3.

    UICollectionViewʹSwiftUIΛར༻͢Δ • HostingCollectionViewCellͰ೚ҙͷSwiftUIͷViewΛදࣔͰ͖Δ • Self-Sizingʹ΋ରԠͰ͖Δ
  35. બ୒ࢶ 1. SwiftUIΛϕʔεʹ࣮૷͠ɺUIKitΛҰ෦Ͱར༻͢Δ 2. UIKitΛϕʔεʹ࣮૷͠ɺSwiftUIΛҰ෦Ͱར༻͢Δ 3. UIKitͷΈͰ࣮૷͢Δ

  36. ΞʔΩςΫνϟ Domain Core Feature Feature Feature UI App

  37. View View Interactor Interactor ϑϩʔ ViewController Presenter Interactor Coordinator UIView

    or View Repository
  38. ·ͱΊ • ໰୊఺ • SwiftUI͸ը໘ભҠϩδοΫΛ؆୯ʹ͸ണ͕ͤͳ͍ • SwiftUI࣌୅ͷ࣮૷ύλʔϯ͕ඞཁʹͳΔʢ͔΋͠Εͳ͍ʁʣ • SwiftUI͸ैདྷAnalyticsπʔϧͰ͸ը໘ભҠΛτϥοΩϯάͰ͖ͳ͍ •

    ରԠࡦ • UIKitΛϕʔεʹΞϓϦΛઃܭ • SwiftUIΛUIίϯϙʔωϯτͱͯ͠࠾༻
  39. ࢀߟ https://developer.apple.com/videos/play/wwdc2020/10119/ https://khanlou.com/2015/10/coordinators-redux/ https://firebase.google.com/docs/analytics/screenviews?hl=ja https://jobandtalent.engineering/ios-architecture-an-state-container-based- approach-4f1a9b00b82e