Issue #164Swift & Indie ShippingUpdated Reference Archive

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 AreaFrequent Indie MistakePreventive Action
2.1 CompletenessDemo account expired or behind 2FAProvide static reviewer credentials in App Store Connect notes
3.1.2 SubscriptionsMissing Restore Purchases button or terms linkDisplay restore action + EULA/Privacy links directly on paywall
5.1.1 PrivacyRequesting tracking/notifications on first launchDefer permission prompts until user triggers the feature

Related Reading