Hello, I have a question about Kotlin-Swift inter...
# multiplatform
f
Hello, I have a question about Kotlin-Swift interop. When accessing the value 'COPY_MESSAGE' of an enum in Swift, I get 'theCopyMessage'. Could you please explain the reason behind these name changes and how to address this behavior? initial enum
Copy code
public enum class CallToolType {
  SPEAKER,
  MICROPHONE,
  CAMERA,
  COPY_MESSAGE
}
result in swift
Copy code
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("CallToolType")))
@interface CorsairCallToolType : CorsairKotlinEnum<CorsairCallToolType *>
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
- (instancetype)initWithName:(NSString *)name ordinal:(int32_t)ordinal __attribute__((swift_name("init(name:ordinal:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
@property (class, readonly) CorsairCallToolType *speaker __attribute__((swift_name("speaker")));
@property (class, readonly) CorsairCallToolType *microphone __attribute__((swift_name("microphone")));
@property (class, readonly) CorsairCallToolType *camera __attribute__((swift_name("camera")));
@property (class, readonly) CorsairCallToolType *theCopyMessage __attribute__((swift_name("theCopyMessage")));
+ (CorsairKotlinArray<CorsairCallToolType *> *)values __attribute__((swift_name("values()")));
@property (class, readonly) NSArray<CorsairCallToolType *> *entries __attribute__((swift_name("entries")));
@end
thank you ! 🙏
j
Kotlin/Native has to generate Objective-C compatible code, and it tries to avoid naming conflicts with Objective-C keywords and conventions Maybe COPY_MESSAGE is reserved n Objective-C
f
I think so, but I would like to know why 😄 thx for your clue about keywords / conventions with Objective-C. I check !
1