Hi, I'm encountering a peculiar issue that seems s...
# multiplatform
q
Hi, I'm encountering a peculiar issue that seems similar to a post I recall seeing on Slack Chats or YouTrack (which I can't locate now). In that post, it was mentioned that if an object class contains an uppercase DEBUG variable, iOS builds fail with a syntax error, and the solution was to rename it to lowercase debug. Currently, I'm facing a problem where I've declared a class in a
commonMain
module with a
var description: String = ""
property. However, when accessing it from Swift, it inexplicably returns the class object's default description instead of the actual string value. Here's a minimal example: // Kotlin: com.test.data.TestDto.kt
Copy code
@Serializable
class TestDto {
    var title: String = "title"
    var description: String = "description"
}
// Swift usage
Copy code
public func test(_ dto: TestDto) {
    print("dto.title => \(dto.title)")
    print("dto.description => \(dto.description)")
}
// Actual output:
Copy code
dto.title => title  
dto.description => com.test.data.TestDto@xxxxxxx
The
title
property works as expected. Xcode debugger shows the correct value for description in breakpoints, suggesting the data is present. Both properties are declared identically in Kotlin (String type with default values). This behavior specifically affects the description property name. Renaming it (e.g., to desc) resolves the issue, but I need clarity on why this happens and whether it’s related to reserved keywords in Swift/Kotlin interoperability. Has anyone encountered similar issues with property names like description in KMP? Any insights into underlying causes or workarounds (besides renaming) would be appreciated!
🧵 5
👀 1
Looks like no one else has encountered this exact issue. I'll proceed with filing it on YouTrack: KT-78669: Unexpected Behavior Accessing Kotlin 'description' Property from Swift Returns Object Reference Instead of Value