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
120
Detail-oriented UI with Layout Margins @NSSpain 2019
hybridcattt
2
530
Collection Views: Diffable Data Sources and Compositional Layout | Workshop @SwiftIsland 2019
hybridcattt
0
250
Detail-oriented UI with Layout Margins
hybridcattt
1
310
Flow Coordinators IRL
hybridcattt
0
150
SaaS- SDK as a service
hybridcattt
0
150
Other Decks in Technology
See All in Technology
AI とペアプロしてわかった 3 つのヒューマンエラー
takahiroikegawa
0
310
AIエージェント実践集中コース LT
okaru
1
190
やさしいClaude Code入門
minorun365
PRO
40
32k
Eight Engineering Unit 紹介資料
sansan33
PRO
0
3.4k
Roo CodeとClaude Code比較してみた
pharma_x_tech
1
110
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
6.7k
入門 ESlint Typegen #TSKaigi #TSKaigi2025_kataritai
bengo4com
0
2k
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
6.2k
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
2.6k
AIとSREの未来 / AI and SRE
ymotongpoo
2
1.8k
不安定だったテストが信頼を取り戻すまで / The Road to Trustworthy Tests
katawara
0
130
Drawing with LLMs
rist
0
200
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
25
2.8k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
The Pragmatic Product Professional
lauravandoore
35
6.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.7k
Code Review Best Practice
trishagee
68
18k
Java REST API Framework Comparison - PWX 2021
mraible
31
8.6k
Facilitating Awesome Meetings
lara
54
6.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
48
5.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
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