r/iOSProgramming • u/reverendo96 • Feb 07 '26
Discussion The secret to buttery smooth SwiftUI
This morning at 1 am (always when you say “this is the last post I read then I go to sleep) I found one of the best resources about SwiftUI in a while:
An article explaining how SwiftUI rendering works
https://www.swiftdifferently.com/blog/swiftui/swiftui-performance-article
The agent skill created with the article’s knowledge in mind:
https://skills.sh/avdlee/swiftui-agent-skill/swiftui-expert-skill
Hope you find it useful
188
Upvotes
15
u/liquidsmk Feb 07 '26
thanks for the write up. Before i even clicked the link i went and made a cup of tea thinking it would be long read. Nice and to the point. And i too have fell victim to all three of those false solutions.
5
u/[deleted] Feb 07 '26
There are good tips in there, but I see 2 issues with the material.
and the last note: SwiftUI profiler is your friend. You can check how long it took for what aspect of rendering to happen, etc. Really, just give it a try
30
u/staninprague Feb 07 '26
When you come from Silverlight/WPF through UIKit to SwiftUI - that's a strong dejavu feeling when reading this article and memories come back of several days long performance tuning sessions for the WPF/Silverlight, and all these subtle and not subtle bugs you had to solve with each new version :). Using swiftUI and android Compose now, it looks like they picked up where WPF/Silverlight failed, with one of the most important factors being transparency in how they work -> this article. Gives hope even to old pessimists like me. I still failed, even after 2 days of tuning, to build a list of bluetooth discovery for ~20 devices with real time (1Hz) data update without hitting ~50% of iPhone's CPU in SwiftUI, no problem with UIKit with ~4% CPU.
10
u/Gullible-Notice-6192 Feb 07 '26
Great read
11
u/paradoxally objc_msgSend Feb 07 '26
I love how you need to find some obscure blog article where someone has managed to tame SwiftUI into behaving properly. Almost as if it were some arcane magic.
Meanwhile, UIKit is right there and doesn't need hacks to achieve 120 FPS scrolling.
4
u/notrandomatall Feb 07 '26
This is fantastic, thanks for sharing!
4
u/Bsomin Feb 08 '26
Ai slop makes this so hard to read
7
u/[deleted] Feb 07 '26
The difficult thing is exactly passing closures into SwiftUI Views.
It's VERY awkward the way SwiftUI is designed to have to manually add Equatable conformance, add the equatable function, write the proper checks for all properties EXCEPT the closures (tanks future managability), have the PARENT add the .equatable() modifier.
This is such a bad design imo.
2
u/Its-all-redditive Feb 07 '26
Thanks for this, perfect timing on a personal hobby project.
Just a heads up, the npx install universal agent writes to ~/.agents/skills even for Claude Code which won’t recognize it. It should be writing to ~/.claude/skills for it to show up in skills.