Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security NachrichtenIT Security News Hourly Summary 2026-09-21 23h : 7 posts(21.09.2026 um 23:00 Uhr)
IT Security NachrichtenBigCommerce alerts merchants of data breach linked to Ribon apps(21.09.2026 um 23:18 Uhr)
IT Security DownloadsGitHub Release: matomo-org/matomo v5.14.0 (21.09.2026)(21.09.2026 um 23:11 Uhr)
IT NachrichtenWarner-Übernahme ist durch: Paramount erzielt Vergleiche(21.09.2026 um 22:48 Uhr)
IT Security NachrichtenIT Security News Hourly Summary 2026-09-21 23h : 7 posts(21.09.2026 um 23:00 Uhr)
IT Security NachrichtenBigCommerce alerts merchants of data breach linked to Ribon apps(21.09.2026 um 23:18 Uhr)
IT Security DownloadsGitHub Release: matomo-org/matomo v5.14.0 (21.09.2026)(21.09.2026 um 23:11 Uhr)
IT NachrichtenWarner-Übernahme ist durch: Paramount erzielt Vergleiche(21.09.2026 um 22:48 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

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

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…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

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






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.






The fix (one custom decoder)



I wrote a custom init(from:) that uses decodeIfPresent for all fields with defaults:




struct Event: Identifiable, Codable, Hashable {
var id: UUID = UUID()
var title: String
var date: Date
var emoji: String = "🎯"
var colorID: String = "default"
var createdAt: Date = .now
var isRecurring: Bool = false

enum CodingKeys: String, CodingKey {
case id, title, date, emoji, colorID, createdAt, isRecurring
}

init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: CodingKeys.self)
self.id = try c.decode(UUID.self, forKey: .id)
self.title = try c.decode(String.self, forKey: .title)
self.date = try c.decode(Date.self, forKey: .date)
self.emoji = try c.decodeIfPresent(String.self, forKey: .emoji) ?? "🎯"
self.colorID = try c.decodeIfPresent(String.self, forKey: .colorID) ?? "default"
self.createdAt = try c.decodeIfPresent(Date.self, forKey: .createdAt) ?? .now
self.isRecurring = try c.decodeIfPresent(Bool.self, forKey: .isRecurring) ?? false
}
}






The synthesized encode(to:) stays as-is. Encoding always writes current fields; decoding tolerates missing ones from older clients.



One key: I applied decodeIfPresent to all fields with defaults, not just the new one. This future-proofs the decoder — every schema v1.0.1+ migration is now precedented.






Why I applied this to three apps that don't currently need it



DaysUntil got the fix immediately (it needed it). But here's what happened next:



I checked AltitudeNow. Same pattern: persisted Location struct, four default-valued fields.



I checked PromptVault. Same: persisted Prompt struct, five defaults.



I checked AutoChoice. Same: persisted Choice struct, three defaults.



None of these apps have added a field yet. But all of them will, eventually. The moment they ship v1.0.1 with a new feature, the migration trap appears.



So I applied the same decoder pattern to all four. Same pattern, same tests, same future-proofing. Total time: 2 hours for all four repos. Cost of not doing it now: debugging the crash on day-1 of each future release.






The test I added to each repo






func testDecodingOldEventSchemaWithoutIsRecurring() throws {
let oldJSON = #"""
{
"
id": "00000000-0000-0000-0000-000000000001",
"
title": "Old Event",
"
date": 777600000,
"
emoji": "🎯",
"
colorID": "default",
"
createdAt": 777600000
}
"""
#.data(using: .utf8)!

let decoded = try JSONDecoder().decode(Event.self, from: oldJSON)
XCTAssertEqual(decoded.title, "Old Event")
XCTAssertFalse(decoded.isRecurring)
}






This test passes the v1.0.0 schema through the v1.0.1 decoder. If you forget the custom init(from:), it fails with keyNotFound. Better to catch in CI than in App Review.






The leverage pattern



This is the kind of work that doesn't show up in a "what I shipped" list. No visible feature. No new button. No marketing copy.



But it saves:




  • Zero crash reports on day-1 of four future releases

  • Zero "the app deleted my data" support messages

  • Zero debugging the same trap four times across four code bases



The pattern I'm applying now:





  1. Every persisted struct gets a custom init(from:) the moment it ships, not after it breaks.


  2. Use decodeIfPresent for all fields with defaults, not just the new ones.


  3. One backwards-compat test per struct that encodes the v1.0.0 schema, decodes it, asserts no throw.



Boring boilerplate on day-1. But day-60, when I'm shipping v1.0.1 across four apps, I don't have four migration bugs to debug.






What scales and what doesn't



If you're building multiple iOS apps:



Scales: Custom decoder pattern. Applied to four apps, caught zero regressions in CI, cost 20 minutes per app.



Doesn't scale: Manual testing. Each app's persisted structs are unique; you can't test one migration and assume the others are fine.



Scales: Shared test template. I copied the test structure across all four repos. CI caught any typos.



The meta-lesson: schema migration is the invisible foundation of persisted data. Systematize it early, apply it everywhere, then you can stop thinking about it.






The Event struct and tests are in my open-source iOS apps on GitHub.



If you're shipping v1.0.1 of an iOS app with new persistent fields, drop a comment — happy to share other migration patterns I've seen scale.



Sources:



Ähnliche Beiträge
🔍 Verwandte News

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

Thematisch verwandte Begriffe: rebuilt, Codable, migration, pattern · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-45381 | Tautulli is a Python based monitoring and tracking tool for Plex Media S…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick