Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Demystifying SwiftUI Previews
Marina
April 08, 2022
Technology
0
42
Demystifying SwiftUI Previews
Understand how SwiftUI previews work, why they pause, and how to fix it.
Marina
April 08, 2022
Tweet
Share
More Decks by Marina
See All by Marina
Detail-oriented UI with Layout Margins @NSSpain 2019
hybridcattt
2
320
Collection Views: Diffable Data Sources and Compositional Layout | Workshop @SwiftIsland 2019
hybridcattt
0
88
Detail-oriented UI with Layout Margins
hybridcattt
1
130
Flow Coordinators IRL
hybridcattt
0
82
SaaS- SDK as a service
hybridcattt
0
66
Other Decks in Technology
See All in Technology
CSS Variable をもっと活用する / Kyoto.js 18
spring_raining
2
300
OCI DevOps 概要 / OCI DevOps overview
oracle4engineer
PRO
0
490
ユーザーテストガイドライン VERSION 2.0
kouzoukaikaku
0
1.3k
【Λ(らむだ)】WinActorから始めるいつのまにリスキリング / WinAtorライトニングトーク大会20230123
lambda
0
100
20230123_FinJAWS
takuyay0ne
0
120
USB PD で迎える AC アダプター大統一時代
puhitaku
2
1.9k
Pentesting Password Reset Functionality
anugrahsr
0
460
SPA・SSGでSSRのようなOGP対応!
simo123
2
150
WebLogic Server for OCI 概要
oracle4engineer
PRO
3
880
スクラム導入して変わったチーム、組織のありかた
yumechi
0
190
Kaggleシミュレーションコンペの動向
nagiss
0
270
API連携に伴う規制と対応 / Regulations and responses to API linkage
moneyforward
0
150
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
270
12k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
120
29k
The Invisible Customer
myddelton
113
12k
How To Stay Up To Date on Web Technology
chriscoyier
779
250k
Building a Scalable Design System with Sketch
lauravandoore
451
31k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
227
16k
What the flash - Photography Introduction
edds
64
10k
A Philosophy of Restraint
colly
193
15k
The Cult of Friendly URLs
andyhume
69
5.1k
What’s in a name? Adding method to the madness
productmarketing
12
1.9k
YesSQL, Process and Tooling at Scale
rocio
159
12k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
6
840
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