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
98
Detail-oriented UI with Layout Margins @NSSpain 2019
hybridcattt
2
460
Collection Views: Diffable Data Sources and Compositional Layout | Workshop @SwiftIsland 2019
hybridcattt
0
220
Detail-oriented UI with Layout Margins
hybridcattt
1
270
Flow Coordinators IRL
hybridcattt
0
120
SaaS- SDK as a service
hybridcattt
0
120
Other Decks in Technology
See All in Technology
GoogleのAIエージェント論 Authors: Julia Wiesinger, Patrick Marlow and Vladimir Vuskovic
customercloud
PRO
0
110
embedパッケージを深掘りする / Deep Dive into embed Package in Go
task4233
1
200
信頼されるためにやったこと、 やらなかったこと。/What we did to be trusted, What we did not do.
bitkey
PRO
0
2.1k
🌏丸い地球を効率的に平たくする 〜🗺️地図の幾何学とWeb地図技術〜
syotasasaki593876
0
140
JAWS-UG20250116_iOSアプリエンジニアがAWSreInventに行ってきた(真面目編)
totokit4
0
130
駆け出しリーダーとしての第一歩〜開発チームとの新しい関わり方〜 / Beginning Journey as Team Leader
kaonavi
0
120
AWSサービスアップデート 2024/12 Part3
nrinetcom
PRO
0
140
カップ麺の待ち時間(3分)でわかるPartyRockアップデート
ryutakondo
0
130
2025年に挑戦したいこと
molmolken
0
150
EMConf JP の楽しみ方 / How to enjoy EMConf JP
pauli
2
140
2025年の挑戦 コーポレートエンジニアの技術広報/techpr5
nishiuma
0
140
AWSマルチアカウント統制環境のすゝめ / 20250115 Mitsutoshi Matsuo
shift_evolve
0
100
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
327
24k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
570
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
The Power of CSS Pseudo Elements
geoffreycrofte
74
5.4k
Navigating Team Friction
lara
183
15k
Producing Creativity
orderedlist
PRO
343
39k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Building Applications with DynamoDB
mza
93
6.2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
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