Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Xcode 16のPreviewModifierと@Previewableを活用した効率的なプ...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ojun
July 05, 2024
Programming
1.2k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Xcode 16のPreviewModifierと@Previewableを活用した効率的なプレビュー方法の考察
ojun
July 05, 2024
More Decks by ojun
See All by ojun
配列と所有権
ojun9
0
93
生成 AI 時代のスナップショットテストってやつを見せてあげますよ(α版)
ojun9
0
450
アセットのコンパイルについて
ojun9
0
290
Exit 8 for SwiftUI
ojun9
1
310
Swift Evolution かるた
ojun9
2
150
Catch Up with Swift 5.10
ojun9
2
940
Overview: Swift OpenAPI Generator
ojun9
3
2.7k
if 式と switch 式による SwiftUI のプレビューエラー対策
ojun9
1
2.3k
楽しい夏休み!String Catalogs で新しい発見
ojun9
0
2.6k
Other Decks in Programming
See All in Programming
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2k
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
340
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.3k
Java 27新機能 / Java 27 new features
kishida
2
180
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
170
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
720
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
360
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
4.8k
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5.2k
モバイル交通系ICへのチャージ実例から考える、クロスプラットフォーム開発におけるiOS実機テスト設計とCI運用
yusuga
1
550
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
320
App Intentsのビルドプロセスを支える技術
kntkymt
0
470
Featured
See All Featured
Chasing Engaging Ingredients in Design
codingconduct
0
340
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
So, you think you're a good person
axbom
PRO
2
2.2k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
510
For a Future-Friendly Web
brad_frost
183
10k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Balancing Empowerment & Direction
lara
6
1.3k
The Spectacular Lies of Maps
axbom
PRO
1
1k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
290
Deep Space Network (abreviated)
tonyrice
0
330
Product Roadmaps are Hard
iamctodd
55
13k
My Coaching Mixtape
mlcsv
0
330
Transcript
potatotips #88 iOS/Android։ൃTipsڞ༗ձ 2024/07/05 @STORES Xcode 16ͷPreviewModifierͱ@Previewable Λ׆༻ͨ͠ޮతͳϓϨϏϡʔํ๏ͷߟ ojun -
DeNA Co., Ltd.
ࣗݾհʢojunʣ • name: ojun • 2023৽ଔೖࣾ • iOSΤϯδχΞ @ojun_9
Xcode 16ͷ PreviewModifier ͱ @Previewable Λ׆༻ͨ͠ޮతͳϓϨϏϡʔํ๏ͷߟ
PreviewModifier ͱ ˏPreviewable ʹ͍ͭͯ
@Previewable ʹ͍ͭͯ @Previewable Xcode 16 ͰՃ͞ΕͨϚΫϩ ϓϩύςΟʔϥούʔʹରͯ͠దԠ͢Δ͜ͱ͕Ͱ͖Δ #Previewͷ෦Ͱ༻Մೳ iOS
ʹؔͯ͠ iOS 18 Ҏ্Ͱಈ࡞͢Δ
None
PreviewModifierʹ͍ͭͯ PreviewModi fi er Xcode 16 ͰՃ͞Εͨprotocol iOS ʹؔͯ͠
iOS 18 Ҏ্Ͱಈ࡞͢Δ
None
None
None
None
None
None
None
None
Context Context
Context Context View
Context Context View
Context Context View
None
͜ͷ2ͭͷػೳΛݟͨ࣌ʹͲ͏ࢥ͍·ͨ͠ ͔ʁ
͜ͷ2ͭͷػೳΛݟͨ࣌ʹͲ͏ࢥ͍·͔ͨ͠ʁ ݸਓతʹ͜ΕΒͷػೳΛ࠷ॳʹݟͨ࣌ʮѻ͏ͷ͕େͦ͠͏ʯͱࢥͬͨ
͜ͷ2ͭͷػೳΛݟͨ࣌ʹͲ͏ࢥ͍·͔ͨ͠ʁ ݸਓతʹ͜ΕΒͷػೳΛ࠷ॳʹݟͨ࣌ʮѻ͏ͷ͕େͦ͠͏ʯͱࢥͬͨ
͜ͷ2ͭͷػೳΛݟͨ࣌ʹͲ͏ࢥ͍·͔ͨ͠ʁ ݸਓతʹ͜ΕΒͷػೳΛ࠷ॳʹݟͨ࣌ʮѻ͏ͷ͕େͦ͠͏ʯͱࢥͬͨ
͜ͷ2ͭͷػೳΛݟͨ࣌ʹͲ͏ࢥ͍·͔ͨ͠ʁ makeSharedContext() ͷ͍ํ͕؊ʹͳΔ mockαʔόͱ௨৴͢Δʁ → PreviewͰͦ͜·Ͱ͢Δͷ͔ʁ ݸਓతʹ͜ΕΒͷػೳΛ࠷ॳʹݟͨ࣌ʮѻ͏ͷ͕େͦ͠͏ʯͱࢥͬͨ
PreviewModifier ͱ @PreviewableΛ׆ ༻ͨ͠ޮతͳϓϨϏϡʔํ๏ͷߟ
લఏͱͳΔViewͷ࡞ SNSͷλΠϜϥΠϯΛߟ͑Δ
લఏͱͳΔViewͷ࡞ SNSͷλΠϜϥΠϯΛߟ͑Δ ߘΛද͢ߏମΛఆٛ
લఏͱͳΔViewͷ࡞ SNSͷλΠϜϥΠϯΛߟ͑Δ ViewΛఆٛ [Post] Λ࣋ͪ body Ͱར༻
લఏͱͳΔViewͷ࡞
લఏͱͳΔViewͷ࡞
લఏͱͳΔViewͷ࡞ PreviewͰͬͱද͍ࣔͤͨ͞ʂ
લఏͱͳΔViewͷ࡞
લఏͱͳΔViewͷ࡞
લఏͱͳΔViewͷ࡞
લఏͱͳΔViewͷ࡞ ಡΈࠐΈ࣌ͷ Placeholder େৎ͔ͳʁ ໊લ͘ͳͬͨ࣌େৎ͔ͳʁ վߦ͞ΕͨΒେৎ͔ͳʁӳޠɾֆจࣈͷ࣌ େৎ͔ͳ ͍͍Ͷͷ͕ଟ͍࣌େৎ͔ͳ 0݅ͷ࣌ඇදࣔʹͳΔ͔ͳʁ
લఏͱͳΔViewͷ࡞ ඞཁͳύλʔϯͷ Post ΛՃ͢Ε ෳύλʔϯͷ Preview Մೳ ͔͠͠ӈਤͷΑ͏ʹ͔ͳΓݟͮΒ͘ͳΔ
લఏͱͳΔViewͷ࡞ ඞཁͳύλʔϯͷ Post ΛՃ͢Ε ෳύλʔϯͷ Preview Մೳ ͔͠͠ӈਤͷΑ͏ʹ͔ͳΓݟͮΒ͘ͳΔ @Previewable
PreviewModi fi er Λར༻͠ ղܾ͢Δ
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ 1. JSONϑΝΠϧΛ࡞͠ɺඞཁͳσʔλΛՃ͢Δ
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ 1. JSONϑΝΠϧΛ࡞͠ɺඞཁͳσʔλΛՃ͢Δ 1. ʢࠓճ ChatGPT Λར༻ͯ͠࡞ʣ
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ 1. JSONϑΝΠϧΛ࡞͠ɺඞཁͳσʔλΛՃ͢Δ 1. ʢࠓճ ChatGPT Λར༻ͯ͠࡞ʣ
2. ʢ࡞͠Ճ͢Δ͚ͩͳͷͰׂѪʣ
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ 1. JSONϑΝΠϧΛ࡞͠ɺඞཁͳσʔλΛՃ͢Δ 1. ʢࠓճ ChatGPT Λར༻ͯ͠࡞ʣ
2. ʢ࡞͠Ճ͢Δ͚ͩͳͷͰׂѪʣ 2. JSONϑΝΠϧΛಡΈࠐΈ decode ͠ Preview ʹೖ
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ let posts: [Post] ͕ @Environment Ͱͳ͍߹
@Previewable Λར༻͢Δͱྑͦ͞͏
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ .task {} ͘͠ .onAppear {} Λ
ར༻ͦ͠ͷதͰಡΈࠐΈΛߦ͏
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ .task {} ͘͠ .onAppear {} Λ
ར༻ͦ͠ͷதͰಡΈࠐΈΛߦ͏ decode ͕ޭͨ͠Βɺposts ʹೖ ͢Δ
.task {} ͘͠ .onAppear {} Λ ར༻ͦ͠ͷதͰಡΈࠐΈΛߦ͏ decode ͕ޭͨ͠Βɺposts ʹೖ
͢Δ ෳͷύλʔϯͰ Preview ͕Մೳʹͳͬͨ 🎉
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ let posts: [Post] ͕ @Environment Ͱ͋Δ߹
PreviewModi fi er Λར༻͢Δͱྑͦ͞͏
@Previewable PreviewModifier Λར༻͠ղܾ͢Δ
None
None
·ͱΊ
·ͱΊ Xcode 16͔ΒPreviewModi fi er ͱ @Previewable ͕Ճ͞Εͨ ͜ΕΒΛར༻͢Δ͜ͱͰ Preview
ͷମݧ͕ΑΓ্͢Δ JSONϑΝΠϧΛར༻͠ΤϯςΟςΟΛೖ͢Δ͜ͱͰগ͠ͷίʔυͰଟྔͷύλʔϯΛ Preview Ͱ֬ೝ͢Δ͜ͱ͕Մೳ
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ