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
150
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
80
Detail-oriented UI with Layout Margins @NSSpain 2019
hybridcattt
2
420
Collection Views: Diffable Data Sources and Compositional Layout | Workshop @SwiftIsland 2019
hybridcattt
0
200
Detail-oriented UI with Layout Margins
hybridcattt
1
210
Flow Coordinators IRL
hybridcattt
0
100
SaaS- SDK as a service
hybridcattt
0
89
Other Decks in Technology
See All in Technology
ギークの理想が7つ集まるエムスリーで夢を叶えよう - エムスリー株式会社
m3_engineering
1
260
初中級者用如何使用backlog -VALE TUDOEDITION-
in0u
0
140
AOAI Dev Day LLMシステム開発 Tips集
hirosatogamo
15
3.6k
ソフトウェアエンジニアリングの知見を活かして データ基盤をいい感じにする on Snowflake [MIERUNE BBQ #10]
mtpooh
2
150
What if...? 처음부터 다시 LLM 어플리케이션을 개발한다면
huffon
0
1k
VPoEの視点から見た、ヘンリーがサーバーサイドKotlinを使う理由 / Why Server-side Kotlin 2024
cho0o0
1
420
AWSサービスメニュー開発をしていてAWSを好きだ!と感じた瞬間
toru_kubota
0
130
可視化プラットフォームGrafanaの基本と活用方法の全て
hamadakoji
0
230
AIアシスタントの活用で品質の向上と開発ワークフローのスピードアップ
nagix
1
190
ACRiルーム最新情報とAMD GPUサーバーのご紹介
anjn
0
150
E2Eテスト自動化プラットフォームにおけるAIの活用
shift_evolve
0
180
RAGのサービスをリリースして1年3ヶ月が経ちました
segavvy
4
900
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
502
140k
The Cult of Friendly URLs
andyhume
75
5.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
44
4.7k
Designing the Hi-DPI Web
ddemaree
276
34k
How to Ace a Technical Interview
jacobian
274
23k
Typedesign – Prime Four
hannesfritz
37
2.2k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
17
1.5k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
16
1.6k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
19k
Building Your Own Lightsaber
phodgson
101
5.9k
Design by the Numbers
sachag
277
18k
RailsConf 2023
tenderlove
16
720
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