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
160
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
90
Detail-oriented UI with Layout Margins @NSSpain 2019
hybridcattt
2
440
Collection Views: Diffable Data Sources and Compositional Layout | Workshop @SwiftIsland 2019
hybridcattt
0
210
Detail-oriented UI with Layout Margins
hybridcattt
1
250
Flow Coordinators IRL
hybridcattt
0
110
SaaS- SDK as a service
hybridcattt
0
100
Other Decks in Technology
See All in Technology
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
元旅行会社の情シス部員が教えるおすすめなre:Inventへの行き方 / What is the most efficient way to re:Invent
naospon
2
330
Application Development WG Intro at AppDeveloperCon
salaboy
0
180
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
3
380
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
5
560
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
750
Terraform Stacks入門 #HashiTalks
msato
0
350
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
470
AIチャットボット開発への生成AI活用
ryomrt
0
170
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.6k
個人でもIAM Identity Centerを使おう!(アクセス管理編)
ryder472
3
180
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Ruby is Unlike a Banana
tanoku
97
11k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Raft: Consensus for Rubyists
vanstee
136
6.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Happy Clients
brianwarren
98
6.7k
Typedesign – Prime Four
hannesfritz
40
2.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
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