I have a KMP project with a data class like this: ...
# multiplatform
b
I have a KMP project with a data class like this:
Copy code
data class Race(val description: String)
I updated my project from Kotlin 1.9.10 to 1.9.21 and now I’m getting this warning:
Copy code
var MyPackage.Race.description' was renamed to 'var MyPackage.Race.description_' because of a name collision with an another declaration 'func MyPackage.KotlinBase.description() -> Swift.String'. Consider resolving the conflict either by changing the name in Kotlin, or via the @ObjCName annotation. You can also suppress this warning using the 'SuppressSkieWarning.NameCollision' configuration. However using renamed declarations from Swift is not recommended because their name will change if the conflict is resolved.
    (at val description: String defined in com.my.package.core.models.program.Race)
I’m not sure where this came from, nor the best way to resolve it?
d
For some background, see https://youtrack.jetbrains.com/issue/KT-38641/Kotlin-Multiplatform-Objective-C-description-method-name-collision-in-Swift There is a naming collision because for K/N,
Race
(indirectly) extends
NSObject
, but
NSObject
already comes with a
description
property per https://developer.apple.com/documentation/objectivec/nsobject/1418799-description?language=objc The workaround is to choose a different property name in the
Race
class, either by changing the property name directly or by annotating it with
@ObjCName
to change the name exported by K/N to avoid the collision.
b
I understand. I’m just curious why this is showing up now. This code has been in my library for awhile now, but the warning only just started showing up.
Also, I guess I should’ve read the entire warning more closely, and I would’ve seen:
You can also suppress this warning using the ‘SuppressSkieWarning.NameCollision’ configuration.
Notably the
SupressSkieWarning
… Looks like this is a warning that the Touchlab Skie library has added recently, which explains why I just now started seeing it. While I can rename my own object property, I also get the warning for a property in a KTOR enum, which I obviously can’t rename, so that’s unfortunate.
191 Views