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
430
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.2k
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
php-conference-japan-2024
tasuku43
0
270
useSyncExternalStoreを使いまくる
ssssota
6
1k
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
210
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
210
Go の GC の不得意な部分を克服したい
taiyow
2
780
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
740
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
130
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
95
5.2k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
Automating Front-end Workflow
addyosmani
1366
200k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Statistics for Hackers
jakevdp
796
220k
KATA
mclloyd
29
14k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Gamification - CAS2011
davidbonilla
80
5.1k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
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ͷ༗ྉهࣄཧղͷ֬ೝͷΈʹͬͯ·͢