Issue #164 — Swift Codable Edge Cases & App Store Review Traps
Independent Apple developers rarely have a dedicated QA department to catch backend schema drift or surprise App Store Review rejections. Issue #164 focused on defensive Swift Codable patterns and shipping checklists widely discussed across the Apple dev community (including Apple's Swift Codable documentation).
Lossy Array Decoding Without Crashing the Entire Feed
By default, if a single item inside a 50-element JSON array has an unexpected type or missing required key, JSONDecoder throws and discards the entire payload. Wrapping array elements in a lossy container keeps the app functional while logging the malformed entry.
struct LossyElement<T: Decodable>: Decodable {
let value: T?
init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
self.value = try? container.decode(T.self)
}
}
func decodeSafely<T: Decodable>(_ type: T.Type, from data: Data) throws -> [T] {
let raw = try JSONDecoder().decode([LossyElement<T>].self, from: data)
return raw.compactMap(\.value)
}
Pre-Submission App Review Checklist
| Guideline Area | Frequent Indie Mistake | Preventive Action |
|---|---|---|
| 2.1 Completeness | Demo account expired or behind 2FA | Provide static reviewer credentials in App Store Connect notes |
| 3.1.2 Subscriptions | Missing Restore Purchases button or terms link | Display restore action + EULA/Privacy links directly on paywall |
| 5.1.1 Privacy | Requesting tracking/notifications on first launch | Defer permission prompts until user triggers the feature |