Hi folks. I am trying to compile some Kotlin code to Swift, and particularly some enums.
The enums in Swift are compiled as a class instead of a struct. Later on, I want this compiled class to extend from Decodable, but I receive a message "`Implementation of 'Decodable' cannot be automatically synthesized in an extension in a different file to the type`", since they would need to be on the same file.
I wonder if any of you have hit this problem. Is it possible to specify in K/N that a enum should compile to a struct instead of an enum?
s
Sam
09/23/2020, 1:33 PM
ObjectiveC is the communication path between swift and kotlin. ObjC doesn’t have structs and so nothing from Kotlin can be represented as a struct. Codable works with the
NSCoding
protocol under the hood. If your object implements that, it can be serialized and deserialized wherever a
Thank you so much, Sam. That is a pity, and I think a deterrent for using K/N in some cases - here I wanted to share some DTOs between iOS and Android, and having enums extending decodables it is a common use case.