Hi, I’m having an issue with casting to shared Kot...
# multiplatform
u
Hi, I’m having an issue with casting to shared Kotlin/native classes in Swift when building for release. I have the following class in the shared module:
User.UserGenderProperty.Gender
. On the Swift side an object of that class is casted like this:
Copy code
if let gender = attribute.value as? User.UserGenderPropertyGender { ... }
where
attribute
is a
PropertyOption<User.UserGenderProperty.Gender>
and value should be of exactly that type I’m casting to. When printing out the type of
attribute.value
I get
SharedUserUserGenderPropertyGender
which looks to be right. The generated header file looks fine as well:
Copy code
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("User.UserGenderPropertyGender")))
@interface SharedUserUserGenderPropertyGender : SharedKotlinEnum<SharedUserUserGenderPropertyGender *>
+ (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) SharedUserUserGenderPropertyGender *female __attribute__((swift_name("female")));
@property (class, readonly) SharedUserUserGenderPropertyGender *male __attribute__((swift_name("male")));
+ (SharedKotlinArray<SharedUserUserGenderPropertyGender *> *)values __attribute__((swift_name("values()")));
@property (readonly) SharedStringResource *promptInputRes __attribute__((swift_name("promptInputRes")));
@end
But the cast doesn’t succeed in release builds, so apparently
SharedUserUserGenderPropertyGender
in this build type doesn’t conform to
User.UserGenderPropertyGender
for whatever reason. In debug builds all is good. 🤷 I’m at a loss here, does someone have an idea what might be wrong?