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
170
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
95
Detail-oriented UI with Layout Margins @NSSpain 2019
hybridcattt
2
450
Collection Views: Diffable Data Sources and Compositional Layout | Workshop @SwiftIsland 2019
hybridcattt
0
220
Detail-oriented UI with Layout Margins
hybridcattt
1
260
Flow Coordinators IRL
hybridcattt
0
120
SaaS- SDK as a service
hybridcattt
0
110
Other Decks in Technology
See All in Technology
Storage Browser for Amazon S3
miu_crescent
1
130
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
520
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
830
ガバメントクラウドのセキュリティ対策事例について
fujisawaryohei
0
530
alecthomas/kong はいいぞ / kamakura.go#7
fujiwara3
1
300
LINEヤフーのフロントエンド組織・体制の紹介【24年12月】
lycorp_recruit_jp
0
530
5分でわかるDuckDB
chanyou0311
10
3.2k
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
150
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
160
コンテナセキュリティのためのLandlock入門
nullpo_head
2
320
AI時代のデータセンターネットワーク
lycorptech_jp
PRO
1
280
.NET 9 のパフォーマンス改善
nenonaninu
0
500
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
32
6.3k
How GitHub (no longer) Works
holman
311
140k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
4 Signs Your Business is Dying
shpigford
181
21k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
Faster Mobile Websites
deanohume
305
30k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Rails Girls Zürich Keynote
gr2m
94
13k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
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