How to Write Resilient Swift code (and do it faster with Macros)
summary
Team Cook demo shows enums from APIs break when a backend adds a case; solution is an enum with unsupported(String) that preserves unknown values and makes switches exhaustive, plus a proxy server in TypeScript to backfill third‑party APIs. Custom Swift Macros generate the verbose raw‑representable/codable boilerplate (e.g. safe enum, non-empty string decoder, branded id) at compile time, speeding adoption but requiring care: a bad macro expansion can compile yet crash at runtime.
AI-written summary · about
chapters (18)
- 0:00Introduction
- 1:02Resilient Swift code matters
- 3:13Enum inconsistencies
- 6:27Resilient enum decoding
- 12:30Avoid enums for external values
- 14:59Manual enum fixes
- 15:23Swift macros introduction
- 17:52Swift macro implementation
- 20:23Macro expansion demo
- 21:48Testing Swift macros
- 22:32Swift macros in 2024
- 23:15Code safety philosophy
- 24:20Branded types
- 27:37Branded IDs and type safety
- 29:21Units for clarity
- 30:01Codable edge cases
- 32:11Macro safety
- 34:47Summary








