Menu

Post image 1
Post image 2
1 / 2
0

How I rebuilt the Codable migration pattern across 4 iOS apps in 2 hours

DEV Community·孫昊·26 days ago
#q4y8UgsB
#swift#ios#codable#self#four#decoder
Reading 0:00
15s threshold

I was adding a single new feature to DaysUntil: yearly-recurring events. Twenty lines of product code. But underneath, the data layer needed a pattern fix that turned out to apply to four apps, not one. Here's how I systematized it, and why this pattern compounds across every future app I ship. The trigger I added this one line to the Event struct in DaysUntil: var isRecurring : Bool = false Enter fullscreen mode Exit fullscreen mode Innocent, right? It has a default value. Existing JSON from older app versions don't have this key, so the decoder should... just use the default? No. Swift's synthesized Codable decoder ignores property defaults. When it hits JSON without isRecurring , it throws keyNotFound . The app crashes on launch. Users with saved data see a blank list because the try? swallowed the error. This is the trap I see indie iOS devs hit every 2–3 months. It's invisible in dev (you only have new schema) and lights up day-1 of rollout.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More