Decoding a dictionary with enum as key and dropping a case

Because Swift encodes and decodes a dictionary using an enum as the key into an array with alternated values (as explained here: JSON Encoding / Decoding weird encoding of dictionary with enum values and coded here: swift/Codable.swift at main · apple/swift · GitHub), how are we supposed to handle Decodable when we drop a case or rename it?

Because the local data will have an obsolete key and therefore the decode function will fail. But if I try to decode a [String: MyObject] instead of [MyEnum: MyObject], then I will get an error about how the dictionary was actually saved as a string with alternated values.

Is my only option to never drop any case of the enum?

I expect it to fail, but I don't expect it to not give a single way to handle the data (which isn't some unreadable binary but just plain String as an Enum).

I know that encoding/decoding doesn't handle versioning, it's not their responsibility but mine. However, Swift language doesn't give me any tool for that in this very specific case. If I knew that Enum was a pain to handle when adding a removing a case, I would never make it Codable in a Dictionary - because the way it is handled behind the scene doesn't feel natural in Swift.

It is easy to handle format changes in all the other cases, but not this one as the way Swift encodes/decodes data of Dictionary with Enum keys isn't explicit.

Anyway, I'll just keep my legacy cases for the moment... :confused: