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
Demystifying SwiftUI Previews
Search
Marina Vatmakhter
April 08, 2022
Technology
0
190
Demystifying SwiftUI Previews
Understand how SwiftUI previews work, why they pause, and how to fix it.
Marina Vatmakhter
April 08, 2022
Tweet
Share
More Decks by Marina Vatmakhter
See All by Marina Vatmakhter
Bug-Free by Design: Crafting Swift Code That Doesn't Sting
hybridcattt
0
110
Detail-oriented UI with Layout Margins @NSSpain 2019
hybridcattt
2
510
Collection Views: Diffable Data Sources and Compositional Layout | Workshop @SwiftIsland 2019
hybridcattt
0
240
Detail-oriented UI with Layout Margins
hybridcattt
1
300
Flow Coordinators IRL
hybridcattt
0
140
SaaS- SDK as a service
hybridcattt
0
140
Other Decks in Technology
See All in Technology
問 1:以下のコンパイラを証明せよ(予告編) #kernelvm / Kernel VM Study Kansai 11th
ytaka23
3
360
Previewでもここまで追える! Azure AI Foundryで始めるLLMトレース
tomodo_ysys
2
420
AIと共に乗り越える、 入社後2ヶ月の苦労と学習の軌跡
sai_kaneko
1
200
AWSを利用する上で知っておきたい名前解決の話
nagisa53
6
710
Новые мапы в Go. Вова Марунин, Clatch, МТС
lamodatech
0
1.9k
Twelve-Factor-Appから学ぶECS設計プラクティス/ECS practice for Twelve-Factor-App
ozawa
3
160
本当に必要なのは「QAという技術」だった!試行錯誤から生まれた、品質とデリバリーの両取りアプローチ / Turns Out, "QA as a Discipline" Was the Key!
ar_tama
9
2.9k
コードや知識を組み込む / Incorporating Codes and Knowledge
ks91
PRO
0
170
データベース04: SQL (1/3) 単純質問 & 集約演算
trycycle
PRO
0
720
MCPが変えるAIとの協働
knishioka
1
140
大規模サーバーレスプロジェクトのリアルな零れ話
maimyyym
3
150
意思決定を支える検索体験を目指してやってきたこと
hinatades
PRO
0
400
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
179
53k
Fontdeck: Realign not Redesign
paulrobertlloyd
84
5.5k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Building Adaptive Systems
keathley
41
2.5k
Designing for Performance
lara
608
69k
GraphQLとの向き合い方2022年版
quramy
46
14k
The Pragmatic Product Professional
lauravandoore
33
6.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
40
7.2k
It's Worth the Effort
3n
184
28k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
How to Ace a Technical Interview
jacobian
276
23k
Transcript
Demystifying SwiftUI previews Marina Gornostaeva | @hybridcattt
Agenda ! Other use-cases " Preview lifecycle # The build
process $ How live reloading works ⏸ Reduce previews pausing
! Other use-cases
! Other use-cases
" Lifecycle of a SwiftUI preview • Build once •
Live reload on changes • Pause if change is unsupported by live reloading • Repeat
# Build process • For DEBUG • Detect by ENABLE_PREVIEWS
build setting • Use ProcessInfo in runtime
$ Dynamic replacement • Swift feature called @_dynamicReplacement • Pitched
in 2018 • Supports changes in implementation of a function, computed variable, initializer or subscript struct MyStruct { dynamic func x() { print("x") } } extension MyStruct { @_dynamicReplacement(for: x()) func y() { print("y - replaced dynamically") } }
$ Limitations of live reloading • It’s applied to everything
in the current ile • Supported: changes to bodies of functions, properties, initializers • Not supported: • Editing comments • Signature changes • Adding/removing types, functions, properties • Initial value changes • Changes in other iles
⏸ Improving live reloading • Use computed vars • Check
build scripts • Auto-resume previews
Thanks & @hybridcattt https://hybridcattt.com/blog/ ixing-swiftui-previews