Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
iOS Apple Dev Tutorialsとpointfreeのモダン実装を比較する
Search
ああうえ
July 20, 2023
Programming
1
420
iOS Apple Dev Tutorialsとpointfreeのモダン実装を比較する
ああうえ
July 20, 2023
Tweet
Share
More Decks by ああうえ
See All by ああうえ
エンジニアとデザイナーがわかる iPadの画面サイズ対応入門
kwzr
0
110
react-reconcilerでオレオレReact Nativeを作ろう!
kwzr
1
2.1k
iOS・Androidで使える デザインシステムをどう実装するか
kwzr
3
5.3k
Apple Pencilと左利き対応
kwzr
5
2.1k
BitriseでUIの差分検出
kwzr
0
1.4k
CIをGASで継続的に改善したら幸せになった
kwzr
3
1.6k
Other Decks in Programming
See All in Programming
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
CSC509 Lecture 13
javiergs
PRO
0
110
flutterkaigi_2024.pdf
kyoheig3
0
120
subpath importsで始めるモック生活
10tera
0
300
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
290
初めてDefinitelyTypedにPRを出した話
syumai
0
410
Outline View in SwiftUI
1024jp
1
330
Ethereum_.pdf
nekomatu
0
460
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Automating Front-end Workflow
addyosmani
1366
200k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
890
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
96
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Transcript
͋͋͏͑(@_kwzr_) iOS Apple Dev Tutorialsͱ pointfreeͷϞμϯ࣮Λൺֱ͢Δ
ࣗݾհ • ͋͋͏͑(@_kwzr_) • ॴଐ: ৽نࣄۀ෦ɾCTOࣨσβΠϯγεςϜ෦ • ࣄ: ଟiOSΤϯδχΞ •
झຯ: εϓϥɾ͓ֆ͔͖
iOS։ൃΛֶͿʹ...
AppleͷνϡʔτϦΞϧͬͱ͍ͯʂ
AppleͷνϡʔτϦΞϧΛ ͍ͬͯͩ͘͞
iOS Apple Dev Tutorials • SwiftUIͱUIKitͷνϡʔτϦΞϧ͕͋Δ • εςοϓ͝ͱʹஸೡͳઆ໌ • ϖʔδͷ࠷ޙʹ͕͋Γɺཧղ
ΛνΣοΫͰ͖Δ https://developer.apple.com/tutorials/app-dev-training
Scrumdinger(Standups) • SwiftUI൛Ͱ࣮͞Ε͍ͯΔΞϓϦ • λΠϚʔΛઃఆͰ͖ͨΓɺձٞͷ༰ΛԻ ͨ͠ΓɺࢀՃऀΛهͰ͖ΔΞϓϦ
νϡʔτϦΞϧͰֶͿ͜ͱ • ϨΠΞτ(VStack, HStack...) • ΞΫηγϏϦςΟରԠํ๏ • ϞσϧΛ࡞ͬͯListʹө • ը໘ભҠ(NavigationStack)
• ঢ়ଶཧ(@State, @Binding, ObservableObject, ...) • ϥΠϑαΠΫϧ(onAppear, onDisappear)
νϡʔτϦΞϧͰֶͿ͜ͱ • Swift Concurrency • File ManagerΛͬͨӬଓԽ • গ͠ൃలతͳඳը(PathͳͲ) •
Τϥʔը໘ͷදࣔ • OSͷAPIݺͼग़͠(Speech frameworkݖݶͷڐՄ) • ͳͲ
(͏͜Εࣄ͡ΌΜ)
iOSΞϓϦ։ൃΛֶͼ͍ͨਓʹ ͱ͓ͯ͢͢Ίʂʂ
νϡʔτϦΞϧͬͨɺ͜ͷઌͲ͏͢Ε... • UIKitͱֶ͔ͼ͍ͨ → UIKitνϡʔτϦΞϧɺpixivͷνϡʔτϦΞϧ • ΞʔΩςΫνϟͱ͔ςετͱ͔ • യવͱɺΑΓྑ͍ίʔυΛॻ͖͍ͨͱ͔
pointfreeͷϞμϯ࣮ͱൺΔ
pointfreeco/standups • TCAΛ࡞͍ͬͯΔpointfree͕࡞͍ͬͯΔ • ScrumdingerΛΑΓϞμϯʹॻ͍ͯΈͨϓϩδΣΫτ
Ϟμϯ #ͱ
ϓϩδΣΫτߏΛൺֱ͢Δ
None
None
None
φϏήʔγϣϯपΓͷൺֱ
ϓϩδΣΫτߏΛݟΔ • 2ͭͷϓϩδΣΫτ͕͋ͬͨ • StackBased • TreeBased
None
StackBased vs TreeBased • StackBased • AppViewͰNavigationStack(path:)ΛݟͯɺϧʔςΟϯά • TreeBased •
֤View͔ΒnavigationDestinationΛ֤ͬͯը໘ʹભҠ͍ͯ͠Δ • ͦΕͧΕϝϦσϝ͋Γɺ͜Ε͕શਖ਼ղͱ͍͏ͷݱঢ়ͳ͍
ঢ়ଶϕʔεͷφϏήʔγϣϯʹ͍ͯ͠Δ • pointfreeco/swiftui-navigation • SwiftUIͷը໘ભҠͷΛղܾ͍ͯ͠ΔϥΠϒϥϦ • NavigationLinkTabViewঢ়ଶͱը໘ભҠ͕ඥ͔ͮͳ͍ • ྻڍܕΛͬͯը໘ભҠͰ͖ΔΑ͏ʹ͍ͯ͠Δ •
DeepLinkͳͲΛ͘͢͠ͳΔ
None
None
ςετͷൺֱ
ςετίʔυ͕ॻ͔Ε͍ͯΔ • AppleͷνϡʔτϦΞϧʹςετॻ͔Ε͍ͯͳ͍͕ɺpointfreeͷํ ςετ͕ॻ͔Ε͍ͯΔ • ViewModelతͳͭͷϢχοτςετ • ςετΛॻ͚ΔΑ͏ʹ͍ͯ͠Δ(େࣄ)
ViewͷϩδοΫɾঢ়ଶʹؔ͢Δςετ͕ॻ͚Δ • جຊతʹViewͷϢχοτςετΛॻ͘ͷ͍͠ • ϥΠϒϥϦΛ͏ͳͲ͢ΕͰ͖Δ͕... • https://github.com/nalexn/ViewInspector • Ұൠతͳํ: ViewModelతͳͷΛ࡞ΓɺϩδοΫͱঢ়ଶʹؔ͢Δς
ετΛॻ͘
Apple νϡʔτϦΞϧͰςετΛॻ͍ͯΈΔ • MeetingViewͰΘΕ͍ͯΔScrumTimerΫϥελΠϚʔ + ݱࡏͷൃ දऀͷঢ়ଶΛ࣋ͭModel • ͍ɺViewʹঢ়ଶ͕ͬͨΓॻ͔Ε͍ͯΔײ͡Ͱͳ͔ͬͨͷͰɺλΠ Ϛʔ+ঢ়ଶͷςετΛॻ͚ͨ
None
pointfreeͷtimerͷςετ • DateͷΘΓʹclockΛ͍ɺςετίʔυͰ࣌ؒΛਐΊΒΕΔΑ͏ʹ ͍ͯ͠Δ
None
None
None
Dependency InjectionΛ͍ͯ͠Δ • pointfreeco/swift-dependencies
swift-dependencies͕ͳ͍ͱ͖ • ී௨ʹΔͱςετ༻ͷϞοΫΛࠩ͠ࠐΜͩΓ͢ΔͨΊʹɺί ϯετϥΫλͳͲͰΠϯελϯεΛͨ͠Γ͢Δඞཁ • ໘ɻόέπϦϨʔ͠ͳ͖Ό͍͚ͳ͍࣌ͬͱ໘
ͷఏڙ • SpeechClientͷΠϯελϯεΛఏڙ ͍ͨ͠߹ӈͷΑ͏ʹॻ͘ • ςετ༻ɺϓϨϏϡʔ༻ͷΛఏڙ Մೳ
• @Dependency(\.speechClient)ͰSpeechClientͷΠϯελϯεΛऔͬͯ དྷͯ͘ΕΔΑ͏ʹ • Property WrapperͰ͑ͯศར • ClockUUIDͳͲɺΑ͘͏ͷΛඪ४Ͱఏڙ swift-dependencies͕͋Δͱ͖
ͦͷଞ
SpeechRecognizer • ݩʑͷSpeechRecognizer • Իೝࣝ݁ՌΛड͚औΔ + ݁ՌΛอ࣋͢Δ AppleͷνϡʔτϦΞϧ
pointfree൛ SpeechClient • AsyncThrowingStreamͰྲྀ͚ͩ͢ʹ͍ͯ͠Δ
ࡉ͔͍ॻ͖ํͳͲ • ViewଆͰ͏༻ʹInt, Doubleͷ ϓϩύςΟΛ࡞͍ͬͯΔ • গࠞ͠ཚͦ͠͏ AppleͷνϡʔτϦΞϧ
Durationܕͷ༻ • Durationܕ(iOS 16+)ʹஔ͖Θ͓ͬͯΓɺformatͳͲViewଆͰߦͬͯ ͍Δ pointfreeͷ࣮
• iOS 16͔Β͑Δγϯϓϧͳͷʹ DocumentDirectoryͷऔಘํ๏
Previewͷઆ໌จ • ϓϨϏϡʔͷઆ໌จΛදࣔ͢ΔViewΛࠩ͠ࠐΜͰ͍Δ
None
࿔ΒΕ͍ͯͳ͔ͬͨॴ • SwiftUIͷViewಛʹมߋͯ͠ͳͦ͞͏ • ݩ͔Β͔ͳΓ៉ྷʹ࡞ΒΕ͍ͯΔͱࢥͬͨ
͕࣌ؒͳͯͤ͘ͳ͔ͬͨͱ͜Ζ • Identi fi edArrayͷ • pointfreeతʹਪ͠ϙΠϯτͬΆ͍ • ύϑΥʔϚϯε͕ߴ͍ListΛॻ͖͘͢ •
Ϟνϕʔγϣϯͷจ຺Λ͚ͩ͢Ͱֻ͕͔࣌ؒͬͯ͠·͏ • Sendableॻ͍ͯͨΓ
Ϟμϯͱ • ΑΓྑ͍φϏήʔγϣϯ • DeepLink͘͢͠ • ςελϏϦςΟ • DI •
ͷׂ • ύϑΥʔϚϯε • Identi fi edArray • ΑΓ͘ॻ͚ΔAPI
Apple࣮ͷ؆ܿ͞ྑ͍ • ΞϓϦ։ൃ࢝Ίͨͯͷਓ͕ύϑΥʔϚϯεςελϏϦςΟΛؾʹ͢͠ ͗ͯԿ࣮Ͱ͖ͳ͘ͳΔͷΑ͘ͳ͍
ͳΜͱTCA൛࣮͋Δ
TCAͷExamplesʹStandups͕Ճ͞Εͨ • pointfreeco/swift-composable-architecture • 5݄ʹϦϦʔε͞ΕͨTCAͷNavigationػೳͱڞʹStandupsͷαϯϓϧ Ճ͞Εͨ
pointfreeco/standupsͷඍົ͞Λײ͡Δ TreeBasedͷίʔυ͕ͩɺStackBasedͰࣅͨΑ͏ͳ͜ͱΛ͍ͬͯΔ
pointfreeco/standupsͷඍົ͞Λײ͡Δ TreeBasedͷίʔυ͕ͩɺStackBasedͰࣅͨΑ͏ͳ͜ͱΛ͍ͬͯΔ ↓ͳΜ͔ॻ͖Εͦ͏
• ࢠ(ભҠઌ)ͷΞΫγϣϯReducerͷenumͰཏతʹॻ͚Δ TCA
TCA͍͍ͧ (झࢫ͕ͣΕ͖ͯͦ͏) ͜Ε͚ͩͰͳ͍͚Ͳ...
·ͱΊ • AppleͷνϡʔτϦΞϧ࣮ͱpointfreeͷϞμϯ࣮Λൺֱͨ͠ • ςελϏϦςΟύϑΥʔϚϯεΛҙࣝ͢Δ͜ͱͰϞμϯͳ࣮ʹɻ࣮ ެ։͞Ε͍ͯΔͷͰൺֱͯ͠ΈΑ͏ʂ
AppleͷνϡʔτϦΞϧͬͱ͍ͯʂ ↑ͪͳΈʹ͜ͷਓΤΞϓɻνϡʔτϦΞϧͬͨ͜ͱ͋Γ·ͤΜ
ࢀߟ • https://www.pointfree.co/blog/posts/99-modern-swiftui • pointfreeͷ༗ྉهࣄཧղͷ֬ೝͷΈʹͬͯ·͢