Github user apocolipse commented on the issue:
https://github.com/apache/thrift/pull/1084
Also, to anyone using this, I'm making a pretty decent sized change right
now to how `TEnums` work with Swift Enums. Backstory is that Swift enums are
overly opinionated and don't work well if a new enum value is added to a
service and the client hasn't updated.
Other languages handle this pretty easily since enums are just Ints to
them, they simply read and store the value even if it doesn't match a case.
Since Swift's enums are finite and opinionated, and not backed by Ints, this
posed a bit of a challenge. I initially designed the TEnums to be
RawRepresentable Int32 since it just made sense at the time, this let the
library handle read/write generically and the generator only needed to declare
the cases and an empty init case. The problem arose when we saw it failing
when new values came in. Granted it was designed to do so, but we needed a way
internally to gracefully handle that.
As a replacement, I'm removing the RawRepresentable/Int32 requirement on
TEnums, and removing the protocol read from the library as well, they will
retain a rawValue and init(rawValue:) to facilitate serialization and maintain
compatibility with code that may be already using those, but they're no longer
inherently RawRepresentable. The reason for this decision was to add an
`.unknown(Int32)` case that retains the extra value.
This is an opt-in case, so you'll need to use the generator flag
`safe_enums`, but this way you don't lose that information, and in the likely
event you'll pull something that has an unknown enum value and then need to
send it back to a service, you'll retain the appropriate value and maintain
compatibility between server/client version mismatch.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---