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
180
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
グループ ポリシー再確認 (2)
murachiakira
0
170
Road to Go Gem #rubykaigi
sue445
0
1k
AIと共に乗り越える、 入社後2ヶ月の苦労と学習の軌跡
sai_kaneko
0
140
コードや知識を組み込む / Incorporating Codes and Knowledge
ks91
PRO
0
140
Computer Use〜OpenAIとAnthropicの比較と将来の展望〜
pharma_x_tech
4
440
「経験の点」の位置を意識したキャリア形成 / Career development with an awareness of the “point of experience” position
pauli
4
120
Web Intelligence and Visual Media Analytics
weblyzard
PRO
1
5.9k
Dynamic Reteaming And Self Organization
miholovesq
3
690
Oracle Cloud Infrastructure:2025年4月度サービス・アップデート
oracle4engineer
PRO
0
230
【Λ(らむだ)】最近のアプデ情報 / RPALT20250422
lambda
0
130
CodePipelineのアクション統合から学ぶAWS CDKの抽象化技術 / codepipeline-actions-cdk-abstraction
gotok365
5
330
Mastraに入門してみた ~AWS CDKを添えて~
tsukuboshi
0
360
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Faster Mobile Websites
deanohume
306
31k
Six Lessons from altMBA
skipperchong
28
3.7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
178
53k
Fireside Chat
paigeccino
37
3.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.7k
Become a Pro
speakerdeck
PRO
28
5.3k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
The Pragmatic Product Professional
lauravandoore
33
6.6k
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