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
230
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
600
Collection Views: Diffable Data Sources and Compositional Layout | Workshop @SwiftIsland 2019
hybridcattt
0
280
Detail-oriented UI with Layout Margins
hybridcattt
1
380
Flow Coordinators IRL
hybridcattt
0
190
SaaS- SDK as a service
hybridcattt
0
180
Other Decks in Technology
See All in Technology
モダンUIでフルサーバーレスなAIエージェントをAmplifyとCDKでサクッとデプロイしよう
minorun365
4
210
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
小さく始めるBCP ― 多プロダクト環境で始める最初の一歩
kekke_n
1
440
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.6k
インフラエンジニア必見!Kubernetesを用いたクラウドネイティブ設計ポイント大全
daitak
1
370
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
10k
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
190
予期せぬコストの急増を障害のように扱う――「コスト版ポストモーテム」の導入とその後の改善
muziyoshiz
1
2k
Claude_CodeでSEOを最適化する_AI_Ops_Community_Vol.2__マーケティングx_AIはここまで進化した.pdf
riku_423
2
590
Data Hubグループ 紹介資料
sansan33
PRO
0
2.7k
20260204_Midosuji_Tech
takuyay0ne
1
160
Featured
See All Featured
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Embracing the Ebb and Flow
colly
88
5k
The Curious Case for Waylosing
cassininazir
0
240
Evolving SEO for Evolving Search Engines
ryanjones
0
130
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
130
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
160
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
190
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
150
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