Someone knows why such an error would occur when u...
# kotlin-native
s
Someone knows why such an error would occur when using Kotlin code natively compiled for iOS? Instances of kotlin.Error, kotlin.RuntimeException and subclasses aren't propagated from Kotlin to Objective-C/Swift. Other exceptions can be propagated as NSError if method has or inherits @Throws annotation. Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared com.company.projectname.package.SomeDataClass@c808c7b8 from other thread
k
you created an object on 1 thread and accessed it on another
s
Yeah, that would make sense. But somehow, all my SDK functions are built more or less the same way (
object
singletons with methods that return
data
classes). And there's only one specific function that generates that error. It's an external client who's using/testing the SDK, so I will try to gather more information.
k
you do have the option to use @SharedImmutable if the object is global, or freeze the object otherwise
s
Sorry, I was on some emergency and just now coming back on this. Do I have to flag some of my library functions with @SharedImmutable or is it on client side (of the library)?
Looks like it's the library itself, but can it be used in common (multiplatform) code or does it have to be in specific (native) code?