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

How to release apps faster with SwiftUI

Akio Itaya
September 17, 2021

How to release apps faster with SwiftUI

iOSDC JAPAN 2021

Akio Itaya

September 17, 2021
Tweet

More Decks by Akio Itaya

Other Decks in Programming

Transcript

  1. AkkeyLab / AKIO ITAYA
    ࣮ϓϩμΫτΛԻ଎ϦϦʔεͨ͠࿩🚀
    WED, Inc.
    SwiftUIͰ
    1

    View full-size slide

  2. ࣗݾ঺հ
    ໊લɿAKIO ITAYAɹ/ɹAKKEY


    झຯɿۭؒσβΠϯ


    ׆ಈɿ@AkkeyLab


    ̧̥ɿγϧόʔˍTγϟπεϙϯαʔ

    ̧̥ɿݪߘ̎ίϯςϯπ߹ܭ̍̎ϖʔδ


    WED, Inc.


    ݩ Cyberagent, Inc.
    3

    View full-size slide

  3. ࣗݾ঺հ
    ໊લɿAKIO ITAYAɹ/ɹAKKEY


    झຯɿۭؒσβΠϯ


    ׆ಈɿ@AkkeyLab


    ̧̥ɿγϧόʔˍTγϟπεϙϯαʔ

    ̧̥ɿݪߘ̎ίϯςϯπ߹ܭ̍̎ϖʔδ


    WED, Inc.


    ݩ Cyberagent, Inc.
    4

    View full-size slide

  4. ࣗݾ঺հ
    ໊લɿAKIO ITAYAɹ/ɹAKKEY


    झຯɿۭؒσβΠϯ


    ׆ಈɿ@AkkeyLab


    ̧̥ɿγϧόʔˍTγϟπεϙϯαʔ

    ̧̥ɿݪߘ̎ίϯςϯπ߹ܭ̍̎ϖʔδ


    WED, Inc.


    ݩ Cyberagent, Inc.
    5

    View full-size slide

  5. ࣗݾ঺հ
    ໊લɿAKIO ITAYAɹ/ɹAKKEY


    झຯɿۭؒσβΠϯ


    ׆ಈɿ@AkkeyLab


    ̧̥ɿγϧόʔˍTγϟπεϙϯαʔ

    ̧̥ɿݪߘ̎ίϯςϯπ߹ܭ̍̎ϖʔδ


    WED, Inc.


    ݩ Cyberagent, Inc.
    6

    View full-size slide

  6. ࣗݾ঺հ
    Check Novelty Box!!
    1SPEVDFECZ"LLFZ-BC
    7

    View full-size slide

  7. ࣗݾ঺հ
    ໊લɿAKIO ITAYAɹ/ɹAKKEY


    झຯɿۭؒσβΠϯ


    ׆ಈɿ@AkkeyLab


    ̧̥ɿγϧόʔˍTγϟπεϙϯαʔ

    ̧̥ɿݪߘ̎ίϯςϯπ߹ܭ̍̎ϖʔδ


    WED, Inc.


    ݩ Cyberagent, Inc.
    8

    View full-size slide

  8. Agenda
    1. SwiftUI Ͱ։ൃͨ͠ΞϓϦ


    2. SwiftUI ࠾༻ཧ༝


    3. SwiftUI ϨΠΞ΢τςΫχοΫ


    4. UIKit ΁ͷුؾ


    5. SwiftUI ະରԠϥΠϒϥϦ
    9

    View full-size slide

  9. SwiftUI Ͱ։ൃͨ͠ΞϓϦ
    10

    View full-size slide

  10. د෇͕͙ͦ͢͹ʹɻ
    د෇ઌͷஂମͱد෇ϓϥϯΛબͿ͚ͩɻ1෼Ͱ
    ؆୯ʹد෇͕Ͱ͖ΔΞϓϦͰ͢ɻد෇ͷ͓ྱ
    ͱͯ͠ɺΦϦδφϧεςοΧʔ͕ಧ͘࢓૊Έ
    ʹͳ͍ͬͯ·͢ɻ
    11

    View full-size slide

  11. SwiftUI
    SwiftUI ͱ UIKit ߹ܭΛ100%ͱͯ͠ܭࢉ
    95%
    Ҏ্
    12

    View full-size slide

  12. Engineer
    iOS / GCF / Firebase DB
    01

    13

    View full-size slide

  13. ։ൃظؒ
    େن໛࢓༷มߋ2ճ࣮ࢪ
    02
    ϲ݄
    14

    View full-size slide

  14. SwiftUI ࠾༻ཧ༝
    ॏཁʂ
    15

    View full-size slide

  15. 1. SwiftUI Ͱͷ։ൃྺ༗Γ


    2. ݱঢ়ͷ SwiftUI Ͱ࣮ݱͰ͖Δ UI


    3. ։ൃ 㲗 FB ͷճసεϐʔυΛॏཁࢹ


    4. SwiftUI ʹର͢Δ஌ݟΛ૿΍͢
    SwiftUI ࠾༻ཧ༝
    16

    View full-size slide

  16. 1. SwiftUI Ͱͷ։ൃྺ༗Γ


    2. ݱঢ়ͷ SwiftUI Ͱ࣮ݱͰ͖Δ UI


    3. ։ൃ 㲗 FB ͷճసεϐʔυΛॏཁࢹ


    4. SwiftUI ʹର͢Δ஌ݟΛ૿΍͢
    SwiftUI ࠾༻ཧ༝
    17

    View full-size slide

  17. SwiftUI Ͱͷ։ൃྺ༗Γ
    iOS13 ਖ਼ࣜϦϦʔε਺ϲ݄ޙ

    ݸਓͰ SwiftUI ੡ΞϓϦΛϦϦʔε
    18

    View full-size slide

  18. 1. SwiftUI Ͱͷ։ൃྺ༗Γ


    2. ݱঢ়ͷ SwiftUI Ͱ࣮ݱͰ͖Δ UI


    3. ։ൃ 㲗 FB ͷճసεϐʔυΛॏཁࢹ


    4. SwiftUI ʹର͢Δ஌ݟΛ૿΍͢
    SwiftUI ࠾༻ཧ༝
    19

    View full-size slide

  19. ݱঢ়ͷ SwiftUI Ͱ࣮ݱͰ͖Δ UI
    iOS14 Ҏ͕߱λʔήοτ

    ࡉ͔͍Ξχϝʔγϣϯ΋؆୯ʹ࣮૷Ͱ͖Δ
    20

    View full-size slide

  20. 1. SwiftUI Ͱͷ։ൃྺ༗Γ


    2. ݱঢ়ͷ SwiftUI Ͱ࣮ݱͰ͖Δ UI


    3. ։ൃ 㲗 FB ͷճసεϐʔυΛॏཁࢹ


    4. SwiftUI ʹର͢Δ஌ݟΛ૿΍͢
    SwiftUI ࠾༻ཧ༝
    21

    View full-size slide

  21. ։ൃ 㲗 FB ͷճసεϐʔυΛॏཁࢹ
    Xcode Previews ͰଈνʔϜ΁ڞ༗

    খ͞ͳεύϯͰ։ൃͱमਖ਼Λ܁Γฦ͢͜ͱ͕Մೳʂ
    22

    View full-size slide

  22. 1. SwiftUI Ͱͷ։ൃྺ༗Γ


    2. ݱঢ়ͷ SwiftUI Ͱ࣮ݱͰ͖Δ UI


    3. ։ൃ 㲗 FB ͷճసεϐʔυΛॏཁࢹ


    4. SwiftUI ʹର͢Δ஌ݟΛ૿΍͢
    SwiftUI ࠾༻ཧ༝
    23

    View full-size slide

  23. SwiftUI ʹର͢Δ஌ݟΛ૿΍͢
    ۤઓՕॴΛத৺ʹΞ΢τϓοτ΋

    جຊతʹ SwiftUI ͱ͍͏ڧ੍͍໿Ͱଟ͘ͷֶͼΛಘͨ
    24

    View full-size slide

  24. SwiftUI ϨΠΞ΢τςΫχοΫ
    େن໛࢓༷มߋ΋΢ΣϧΧϜʂ
    25

    View full-size slide

  25. 1. UIKit ͱൺֱ͢ΔΧελϜϘλϯ


    2. εΫϦʔϯϩάͰֶͿॲཧͷڞ௨Խ


    3. Ξχϝʔγϣϯ΁ͷରԠ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    26

    View full-size slide

  26. 1. UIKit ͱൺֱ͢ΔΧελϜϘλϯ


    2. εΫϦʔϯϩάͰֶͿॲཧͷڞ௨Խ


    3. Ξχϝʔγϣϯ΁ͷରԠ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    27

    View full-size slide

  27. SwiftUI ϨΠΞ΢τςΫχοΫ
    օ͞Μ͸ɺͲͷΑ͏ʹ࡞Γ·͔͢ʁ
    28

    View full-size slide

  28. UIKit ver.
    29

    View full-size slide

  29. SwiftUI ϨΠΞ΢τςΫχοΫ
    30

    View full-size slide

  30. SwiftUI ϨΠΞ΢τςΫχοΫ
    UIButton Λܧঝͨ͠ΧελϜΫϥεΛ࡞੒
    31

    View full-size slide

  31. SwiftUI ϨΠΞ΢τςΫχοΫ
    ΦʔόʔϥΠυͯ͠ػೳΛΧελϚΠζ͍ͯ͘͠
    32

    View full-size slide

  32. SwiftUI ϨΠΞ΢τςΫχοΫ
    ೚ҙͷλΠϛϯάͰ૷০
    33

    View full-size slide

  33. SwiftUI ver.
    34

    View full-size slide

  34. SwiftUI ϨΠΞ΢τςΫχοΫ
    35

    View full-size slide

  35. SwiftUI ϨΠΞ΢τςΫχοΫ
    Button ΛؚΉΧελϜϏϡʔΛ࡞੒
    36

    View full-size slide

  36. SwiftUI ϨΠΞ΢τςΫχοΫ
    ૷০͸ελΠϧͱͯ͠ผఆٛ
    Point !
    37

    View full-size slide

  37. SwiftUI ϨΠΞ΢τςΫχοΫ
    ButtonStyle Protocol ʹ४ڌͨ͠ߏ଄ମΛఆٛ
    38

    View full-size slide

  38. SwiftUI ϨΠΞ΢τςΫχοΫ
    ButtonStyleCon
    fi
    guration ߏ଄ମΛҾ਺ʹऔΔؔ਺Λએݴ
    39

    View full-size slide

  39. SwiftUI ϨΠΞ΢τςΫχοΫ
    ButtonStyleCon
    fi
    guration ʹ͸ Button ͷ Label ؚ͕·ΕΔ
    40

    View full-size slide

  40. SwiftUI ϨΠΞ΢τςΫχοΫ
    ϝιουνΣʔϯͰ૷০΍ΞχϝʔγϣϯΛࢪ͢
    41

    View full-size slide

  41. SwiftUI ϨΠΞ΢τςΫχοΫ
    ButtonStyleCon
    fi
    guration ʹ͸ ԡ͞Ε͍ͯΔ͔Λࣔ͢ϑϥάؚ͕·ΕΔ
    42

    View full-size slide

  42. SwiftUI ϨΠΞ΢τςΫχοΫ
    buttonStyle ϝιουʹελΠϧͷΠϯελϯεΛ౉͚ͩ͢
    43

    View full-size slide

  43. 1. UIKit ͱൺֱ͢ΔΧελϜϘλϯ


    2. εΫϦʔϯϩάͰֶͿॲཧͷڞ௨Խ


    3. Ξχϝʔγϣϯ΁ͷରԠ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    44

    View full-size slide

  44. SwiftUI ϨΠΞ΢τςΫχοΫ
    օ͞Μ͸ɺͲͷΑ͏ʹεΫϦʔϯϩάऔΓ·͔͢ʁ
    45

    View full-size slide

  45. SwiftUI ϨΠΞ΢τςΫχοΫ
    46

    View full-size slide

  46. SwiftUI ϨΠΞ΢τςΫχοΫ
    ڞ௨ॲཧ͸ ViewModi
    fi
    er ͱͯ͠ผఆٛ
    47
    Point !

    View full-size slide

  47. SwiftUI ϨΠΞ΢τςΫχοΫ
    48

    View full-size slide

  48. ViewModi
    fi
    er Protocol ʹ४ڌͨ͠ߏ଄ମΛఆٛ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    49

    View full-size slide

  49. Modi
    fi
    er Λࢦఆͨ͠ର৅ͷ View ͕౉ͬͯ͘Δ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    50

    View full-size slide

  50. ର৅ͱͳΔ View ͷ

    onAppear ͰॲཧΛ࣮ߦ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    51

    View full-size slide

  51. ͜͜Ͱ૷০Λߦ͑͹

    ϨΠΞ΢τͷڞ௨Խ͕Մೳʹ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    52

    View full-size slide

  52. 1. UIKit ͱൺֱ͢ΔΧελϜϘλϯ


    2. εΫϦʔϯϩάͰֶͿॲཧͷڞ௨Խ


    3. Ξχϝʔγϣϯ΁ͷରԠ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    53

    View full-size slide

  53. SwiftUI ϨΠΞ΢τςΫχοΫ
    54

    View full-size slide

  54. AnimatableModi
    fi
    er Protocol ʹ४ڌͨ͠ߏ଄ମΛఆٛ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    55

    View full-size slide

  55. ͜ͷมߋ͕Ξχϝʔγϣϯ͠ͳ͕ΒదԠ͞ΕΔΑ͏ʹͳΔ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    56

    View full-size slide

  56. UIKit ΁ͷුؾ
    ̑ˋͷ
    57

    View full-size slide

  57. 1. ුؾ૬ख


    2. ෦෼తʹ UIKit Λར༻͢Δํ๏


    3. ৄ͘͠͸ͪ͜Βʂ
    UIKit ΁ͷුؾ
    58

    View full-size slide

  58. 1. ුؾ૬ख


    2. ෦෼తʹ UIKit Λར༻͢Δํ๏


    3. ৄ͘͠͸ͪ͜Βʂ
    UIKit ΁ͷුؾ
    59

    View full-size slide

  59. UIKit ΁ͷුؾ
    TextField ͕ඞཁͳը໘͸ UIKit Ͱ։ൃ
    60

    View full-size slide

  60. UIKit ΁ͷුؾ
    61
    InputAccessoryView
    ؆୯ʹΩʔϘʔυϝχϡʔΛ࡞੒Մೳ

    View full-size slide

  61. UIKit ΁ͷුؾ
    62
    BecomeFirstResponder
    ࣍ͷೖྗཝʹࣗಈҠಈՄೳ
    ※ iOS15 ͔Β SwiftUI Ͱ΋ਖ਼ࣜαϙʔτ

    View full-size slide

  62. UIKit ΁ͷුؾ
    63
    UIScrollView.setContentOffset
    ೖྗͷ๦͛ʹͳΒͳ͍ҐஔʹεΫϩʔϧ

    View full-size slide

  63. 1. ුؾ૬ख


    2. ෦෼తʹ UIKit Λར༻͢Δํ๏


    3. ৄ͘͠͸ͪ͜Βʂ
    UIKit ΁ͷුؾ
    64

    View full-size slide

  64. SwiftUI ϨΠΞ΢τςΫχοΫ
    65

    View full-size slide

  65. UIViewControllerRepresentable Protocol ʹ४ڌͨ͠ߏ଄ମΛఆٛ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    66

    View full-size slide

  66. UIKit Ͱߏஙͨ͠ΫϥεΛॳظԽ
    SwiftUI ϨΠΞ΢τςΫχοΫ
    67

    View full-size slide

  67. SwiftUI ϨΠΞ΢τςΫχοΫ
    68

    View full-size slide

  68. SwiftUI ϨΠΞ΢τςΫχοΫ
    69

    View full-size slide

  69. SwiftUI ϨΠΞ΢τςΫχοΫ
    70

    View full-size slide

  70. UI ΁൓ө
    SwiftUI ϨΠΞ΢τςΫχοΫ
    71

    View full-size slide

  71. 1. ුؾ૬ख


    2. ෦෼తʹ UIKit Λར༻͢Δํ๏


    3. ৄ͘͠͸ͪ͜Βʂ
    UIKit ΁ͷුؾ
    72

    View full-size slide

  72. UIKit ΁ͷුؾ
    iOSDC ެࣜύϯϑϨοτ΁ܝࡌ

    UIKit ΁ුؾͤ͟ΔΛಘͳ͍͔ҰॠͰ൑அʂ
    73

    View full-size slide

  73. SwiftUI ະରԠϥΠϒϥϦ
    ༉அې෺ʂ
    74

    View full-size slide

  74. 1. ࠇຐज़Λར༻͍ͯ͠ΔSDK


    2. σόοάπʔϧ
    SwiftUI ະରԠϥΠϒϥϦ
    75

    View full-size slide

  75. 1. ࠇຐज़Λར༻͍ͯ͠ΔSDK


    2. σόοάπʔϧ
    SwiftUI ະରԠϥΠϒϥϦ
    76

    View full-size slide

  76. SwiftUI ະରԠϥΠϒϥϦ
    ࣗಈͰεΫϦʔϯϩάΛऔಘͰ͖ͳ͍
    77

    View full-size slide

  77. 1. ࠇຐज़Λར༻͍ͯ͠ΔSDK


    2. σόοάπʔϧ
    SwiftUI ະରԠϥΠϒϥϦ
    78

    View full-size slide

  78. SwiftUI ະରԠϥΠϒϥϦ
    dani-gavrilov/GDPerformanceView-Swift
    79

    View full-size slide

  79. Summary
    1. dim. ͸ SwiftUI Ͱ։ൃ͞Εͨ


    2. ৚݅࣍ୈͰ SwiftUI ࠾༻Ձ஋͋Γ


    3. ButtonStyle, ViewModi
    fi
    er


    4. UIKit ΋͓๨Εͳ͘


    5. ֎෦ϥΠϒϥϦͷಈ࡞֬ೝ͸৻ॏʹ
    81

    View full-size slide

  80. Summary
    1. dim. ͸ SwiftUI Ͱ։ൃ͞Εͨ


    2. ৚݅࣍ୈͰ SwiftUI ࠾༻Ձ஋͋Γ


    3. ButtonStyle, ViewModi
    fi
    er


    4. UIKit ΋͓๨Εͳ͘


    5. ֎෦ϥΠϒϥϦͷಈ࡞֬ೝ͸৻ॏʹ
    82

    View full-size slide

  81. Summary
    1. dim. ͸ SwiftUI Ͱ։ൃ͞Εͨ


    2. ৚݅࣍ୈͰ SwiftUI ࠾༻Ձ஋͋Γ


    3. ButtonStyle, ViewModi
    fi
    er


    4. UIKit ΋͓๨Εͳ͘


    5. ֎෦ϥΠϒϥϦͷಈ࡞֬ೝ͸৻ॏʹ
    83

    View full-size slide

  82. Summary
    1. dim. ͸ SwiftUI Ͱ։ൃ͞Εͨ


    2. ৚݅࣍ୈͰ SwiftUI ࠾༻Ձ஋͋Γ


    3. ButtonStyle, ViewModi
    fi
    er


    4. UIKit ΋͓๨Εͳ͘


    5. ֎෦ϥΠϒϥϦͷಈ࡞֬ೝ͸৻ॏʹ
    84

    View full-size slide

  83. Summary
    1. dim. ͸ SwiftUI Ͱ։ൃ͞Εͨ


    2. ৚݅࣍ୈͰ SwiftUI ࠾༻Ձ஋͋Γ


    3. ButtonStyle, ViewModi
    fi
    er


    4. UIKit ΋͓๨Εͳ͘


    5. ֎෦ϥΠϒϥϦͷಈ࡞֬ೝ͸৻ॏʹ
    85

    View full-size slide

  84. Thank you !!
    87

    View full-size slide