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
210
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
140
Detail-oriented UI with Layout Margins @NSSpain 2019
hybridcattt
2
560
Collection Views: Diffable Data Sources and Compositional Layout | Workshop @SwiftIsland 2019
hybridcattt
0
270
Detail-oriented UI with Layout Margins
hybridcattt
1
350
Flow Coordinators IRL
hybridcattt
0
170
SaaS- SDK as a service
hybridcattt
0
160
Other Decks in Technology
See All in Technology
CNCFの視点で捉えるPlatform Engineering - 最新動向と展望 / Platform Engineering from the CNCF Perspective
hhiroshell
0
130
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
12
81k
Building a cloud native business on open source
lizrice
0
170
ソフトウェアエンジニアの生成AI活用と、これから
lycorptech_jp
PRO
0
830
「REALITY」3Dアバターシステムの7年分の拡張の歴史について
gree_tech
PRO
0
130
AIとともに歩んでいくデザイナーの役割の変化
lycorptech_jp
PRO
0
810
AI-Readyを目指した非構造化データのメダリオンアーキテクチャ
r_miura
1
280
AWS DMS で SQL Server を移行してみた/aws-dms-sql-server-migration
emiki
0
120
事業開発におけるDify活用事例
kentarofujii
5
1.3k
AI時代、“平均値”ではいられない
uhyo
8
2.2k
GraphRAG グラフDBを使ったLLM生成(自作漫画DBを用いた具体例を用いて)
seaturt1e
1
110
Okta Identity Governanceで実現する最小権限の原則 / Implementing the Principle of Least Privilege with Okta Identity Governance
tatsumin39
0
160
Featured
See All Featured
Side Projects
sachag
455
43k
The Illustrated Children's Guide to Kubernetes
chrisshort
49
51k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.7k
The Pragmatic Product Professional
lauravandoore
36
7k
The Straight Up "How To Draw Better" Workshop
denniskardys
238
140k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Build your cross-platform service in a week with App Engine
jlugia
232
18k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
A designer walks into a library…
pauljervisheath
209
24k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
610
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
130k
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