A few weeks ago, I released a new app to the world. Unfortunately, nobody seemed to like it very much. Let’s chalk it up to a rare Jacob Bartlett miss.
But there is an untold story behind the development of the app. A story with nothing to do with my outdated early 2000’s anime references.
A story of SwiftData gone wrong.
And a story of performance pain, of data integrity, and of a successful migration.
I took my nearly-complete app for a test-drive at London Comic-Con. The app took photos and converted them into Top-Trumps-style trading cards with customised names, relevant stat ratings, and different UI effects based on rarity.
I wanted to collect some cool Comic-Con costumes.
In product terms, the app was a massive success. The cosplayers looked great, the shader effects popped, and my client-hosted AI model was handing out accurate names and stats.
But I had twin problems creeping up…
Every time I saved a new card, the app would get slower.
And slower.
And slower.
My battery dwindled rapidly.
I went into low-power mode.
And slower.
And hotter.
And it started crashing.
And got slower.
You get the idea.
Eventually I was waiting 20 seconds between taking a photo and being able to save the card to my collection. Then it would just crash every time.
Something was very wrong with the way I’d implemented SwiftData.
I got home. I knew I had to fix it.
But I also needed to keep my device safe, otherwise I’d lose my hard-earned Comic-Con collection.
So I had my 2 objectives:
Optimise my SwiftData usage to make my app performant…
…without losing all the existing cards I’ve collected
Subscribe to Jacob’s Tech Tavern for free to get ludicrously in-depth articles on iOS, Swift, tech, & indie projects in your inbox every week.
Paid members get several benefits:
Read Elite Hacks, my exclusive advanced content 🌟
See my free articles 3 weeks before anyone else 🚀
Access my brand-new Swift Concurrency course 🧵
Upgrade to read this article right now, or wait until August 4.
Keep reading with a 7-day free trial
Subscribe to Jacob’s Tech Tavern to keep reading this post and get 7 days of free access to the full post archives.