There are 1 page(s) in this tag.
Versioning Codable types in Swift apps (without tearing your hair out)
If you work on codebases any larger than a few lines, at some point you will have to deal with data stored in some sort of document. Inevitably, this type will change, and you’ll need to add, remove, and rearrange fields—while still needing to retain compatibility with stored documents in earlier versions of the format.
This is a problem I’ve recently encountered on my side project, Unspool. Even though I’m the only person ever to have used the app, I still found myself iterating on the data structure to make more logical sense—leading to decoding errors and un-openable documents, along with lots of boilerplate that wouldn’t have been sustainable in the long run. (Read...)