https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
e

Eugene Park

08/04/2022, 5:13 AM
Hi there, I am trying to adopt KMP to define a common schema. I want to use reflection to get a
Map<String, String>
representation of a class's property names/values on Android/iOS. In my commonMain, I define something like `expect fun getPropertyMap(object: BaseObject): Map<String, String>`Where I may pass in some subclass like
class Child : BaseObject()
I was able to get this to work on Android, by using reflection, but am struggling with the iOS implementation. I have tried using the Kotlin
platform.objc
package, but it does not seem to be able to get the property names I also tried writing objective-c code in Xcode against the generated xcframework, but it also returns empty property list. I was wondering if anyone had some suggestions?
Nevermind, I got
kotlinx.serialization
to work on the iOS side. Previously, I had only registered the
SerializationModule
in
commonMain
, which threw some error on iOS side. But creating the module in
iOsMain
did the trick
2 Views