https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
kotlin-native
  • r

    Roman Vasilyev

    01/04/2021, 12:39 AM
    hi, want to join ktor ios websockets development, how I can do it?
    m
    1 reply · 2 participants
  • m

    magnumrocha

    01/05/2021, 6:15 PM
    how to correctly call the function:
    @kotlinx.cinterop.internal.CCall public external fun SCNetworkReachabilityGetFlags(target: platform.SystemConfiguration.SCNetworkReachabilityRef? /* = kotlinx.cinterop.CPointer<cnames.structs.__SCNetworkReachability>? */, flags: kotlinx.cinterop.CValuesRef<platform.SystemConfiguration.SCNetworkReachabilityFlagsVar /* = kotlinx.cinterop.UIntVarOf<kotlin.UInt> */>?): kotlin.Boolean { /* compiled code */ }
    to receive the 
    kSCNetworkReachabilityFlags…
     correctly? in Swift, we can make the call:
    var flags: SCNetworkReachabilityFlags = []
    if !SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags) {
        return false
    }
    And receive the flags in an array style…. In Kotlin Native, I am doing:
    // val flags = allocArray<SCNetworkReachabilityFlagsVar>(10) // -> this was my first attempt, they are 10 possible flags!
    val flags = alloc<SCNetworkReachabilityFlagsVar>()
    
    if (!SCNetworkReachabilityGetFlags(reachabilityRef, flags.ptr)) return false
    the problem is I am receiving all the flag “summed” (they are 
    kotlin.UInt
    ), and not split in an array, like in Swift.
    r
    a
    4 replies · 3 participants
  • m

    mkrussel

    01/05/2021, 8:36 PM
    Does anyone know of any examples of how to define cinterop settings to import a Swift xcframework?
    k
    5 replies · 2 participants
  • a

    Animesh Sahu

    01/06/2021, 8:50 AM
    StableRef
    having object wrapping mutable property vs
    AtomicRef
    ? Which is better to store a mutable object not-frozen (sort of for thread isolation)?
    d
    k
    +1
    16 replies · 4 participants
  • p

    Paul Woitaschek

    01/08/2021, 5:30 PM
    I don’t get it with the
    IncorrectDereferenceException
    It seems I cant use kotlin native on a background thread at all. (kotlin 1.4.21 and coroutines 1.4.2-native-mt)
    import platform.darwin.DISPATCH_QUEUE_PRIORITY_DEFAULT
    import platform.darwin.dispatch_async
    import platform.darwin.dispatch_get_global_queue
    import platform.posix.sleep
    import kotlin.test.Test
    
    class PersonGenerator
    
    class MyTest {
      
      @Test
      fun test() {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT.toLong(), 0)) {
          PersonGenerator()
        }
        sleep(1000)
      }
    }
    Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared MyTest.$test$lambda-0$FUNCTION_REFERENCE$43@8ae08b08 from other thread
    t
    b
    25 replies · 3 participants
  • j

    John O'Reilly

    01/08/2021, 8:35 PM
    Just went through following to enable use of Swift
    await
    and
    async
    https://ohmyswift.com/blog/2020/12/25/experimenting-with-swift-async-and-await-pattern-using-xcode/ Are there any thoughts at this stage, for Kotlin/Native, how this could be mapped to Kotlin suspend functions?
    👍 1
    👀 2
    a
    1 reply · 2 participants
  • s

    savrov

    01/09/2021, 2:53 PM
    hi, does anybody know how i can figure out the reason of endless
    runDebugExecutableNative
    process? google did not give me anything so far…
    a
    2 replies · 2 participants
  • k

    Kai Limadjaja

    01/11/2021, 1:54 PM
    We are using kotlin-native to build a crossplatform library used on android and iOS. On iOS the the binaries for the different apple platforms are bundled in a xcframework and distributed inside a binary SPM-package. Everything works as expected when deploying locally but apple keeps rejecting our binary appstore with the following errors. Anyone has experienced the same and give us a hint how to fix this?
    App Store Connect Operation Error
    ERROR ITMS-90205: "Invalid Bundle. The bundle at '<http://XXXX.app/Frameworks/XXXXMobileShared.framework|XXXX.app/Frameworks/XXXXMobileShared.framework>' contains disallowed nested bundles."
    App Store Connect Operation Error
    ERROR ITMS-90206: "Invalid Bundle. The bundle at '<http://XXXX.app/Frameworks/XXXXMobileShared.framework|XXXX.app/Frameworks/XXXXMobileShared.framework>' contains disallowed file 'Frameworks'."
    g
    4 replies · 2 participants
  • j

    Jérôme Gully

    01/11/2021, 4:56 PM
    Hi, I have a KMM project (android/ios) and I want to add a linuxX64 target to debug purpose (I'm not on mac and my ios colleauge has native problems). My project use sqldelight and it's not supports linuxX64. Is it a way to say to gradle to ingore the dependencie ? I don't need it for my debug.
    l
    5 replies · 2 participants
  • р

    Ролан

    01/11/2021, 7:18 PM
    Hi, if I would like to make sure that all targets (including tests) are compiled with the flag -copt (and not with -g) would adding thid be enough: binaries { all { optimized = true ; debuggable = false }}
    1 reply · 1 participant
  • j

    Jérôme Gully

    01/12/2021, 10:16 AM
    Hi, Is there a way to call
    ensureNeverFrozen
    from common code or swift code ? For the moment I only can access concurrent functions like
    freeze
    and
    ensureNeverFrozen
    in the iosMain shared code. I have an
    InvalidMutabilityException
    calling ktor get function but I only call common code and can't use
    ensureNeverFrozen
    in commin code to debug
    n
    3 replies · 2 participants
  • r

    ribesg

    01/12/2021, 11:17 AM
    cinterop configuration (?) problem I think This commit broke my build https://github.com/bugsnag/bugsnag-cocoa/commit/82fee49fdeb0b46a9855e1fd8f2344f8c03fc0f4 It basically changes all imports from something like
    #import "BugsnagApp.h"
    to something like
    #import <Bugsnag/BugsnagApp.h>
    Error:
    Exception in thread "main" java.lang.Error: /[…]/Carthage/Build/iOS/Bugsnag.framework/Headers/Bugsnag.h:28:9: fatal error: 'Bugsnag/BugsnagApp.h' file not found
    	at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
    	at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1003)
    	at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:992)
    	at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:91)
    	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:267)
    	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:73)
    	at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
    	at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
    	at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:41)
    My def file:
    depends = Foundation
    package = framework.Bugsnag
    language = Objective-C
    headers = Bugsnag.h
    
    compilerOpts = -framework Bugsnag
    linkerOpts = -framework Bugsnag
    Gradle cinterop configuration:
    compilations.getByName("main").cinterops.create("Bugsnag") {
                defFile("src/iosMain/cinterop/Bugsnag.def")
                includeDirs.allHeaders("$projectDir/Carthage/Build/iOS/Bugsnag.framework/Headers")
            }
    What can I do to make cinterop work with that commit’s change?
    a
    9 replies · 2 participants
  • s

    spierce7

    01/12/2021, 8:57 PM
    If I had a a kotlin library running in an AppleTV app, how would I debug the Kotlin code? The KMM plugin makes this easy for an iOS app, but I haven’t found any way to do this on apple tv yet.
    a
    2 replies · 2 participants
  • p

    Paul Woitaschek

    01/13/2021, 4:19 PM
    Could this please get some love? https://youtrack.jetbrains.com/issue/KT-42098
    ⭐ 3
    s
    1 reply · 2 participants
  • n

    Niccolo Machiavelli

    01/14/2021, 12:17 PM
    Hi, why is
    import kotlinx.cinterop.*
    not available when used inside kotlin multiplatform (either commonMain or androidMain) ?
    a
    a
    +2
    25 replies · 5 participants
  • j

    Justin

    01/15/2021, 9:20 PM
    Any support (even experimental) for building Kotlin Native
    macOS-arm64
    frameworks (i.e. for Apple Silicon machines)?
    🤞 5
    l
    j
    3 replies · 3 participants
  • c

    Claus Rørbech

    01/18/2021, 5:08 PM
    I have an issue with
    Undefined symbols for architecture x86_64
    in a KMM project based on https://github.com/Kotlin/kmm-sample/blob/master/README.md. The ios framework (
    :shared:linkDebugFrameworkIos
    ) only fails to link when disabling caching with
    kotlin.native.cacheKind=none
    (or if using Gradle composite builds for the dependencies), but works when using the cache when consuming the dependencies from a Maven repository. The unresolved symbols are defined as custom declarations in a cinterop-wrapper’s def-file and used by static libraries in the dependent module. The klibs passed to konanc seems right and the klibs seems to contain the right symbols in the
    cstubs.bc
    . The only difference on the konanc command line when it works (i.e. without
    kotlin.native.cacheKind=none
    ) is a couple of additional
    -Xcache-directory
    entries, that indeed contains archives containing the symbols. I have tried getting details from the linking phase (by various `freeCompilerArgs`/ `linker-option`s) without luck. Any idea on how to get insight in the linker invocation through konanc or any known limitations/issues around linking against custom declarations in a module’s? The project is available at https://github.com/realm/realm-kotlin/tree/master/examples/kmm-sample
    a
    3 replies · 2 participants
  • j

    Jeff Lockhart

    01/19/2021, 7:52 AM
    Is it possible to cast or convert a
    NSNumber
    Objective-C reference to a Kotlin
    Number
    ? The docs describe casting the other way, but not clear how to accomplish the reverse.
    a
    2 replies · 2 participants
  • k

    Karlo Lozovina

    01/21/2021, 1:47 PM
    does Kotlin Native overlap in some way with what Graal Native Image is trying to do? (compete newb here, just trying to get the lay of the land)
    c
    j
    +2
    7 replies · 5 participants
  • i

    ivan.savytskyi

    01/25/2021, 4:07 PM
    hey folks does anyone saw this kind of error? I'm getting this during building iOS framework. The error doesn't really tell much what causing it. Looking into https://github.com/JetBrains/kotlin-native/blob/7c3329e3e0c06be1e37fd4435bca7d39d88dfc8d/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt#L231 it's all stubs
    e: Compilation failed: org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl@65fe2bcd
    
     * Source files: 
     * Compiler version info: Konan: 1.4.10 / Kotlin: 1.4.10
     * Output kind: FRAMEWORK
    
    e: java.lang.UnsupportedOperationException: org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl@65fe2bcd
            at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor$TopLevelCodeContext.unsupported(IrToBitcode.kt:239)
            at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor$TopLevelCodeContext.genGetValue(IrToBitcode.kt:255)
            at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor$TopLevelCodeContext.genGetValue(IrToBitcode.kt:238)
            at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor$InnerScope.genGetValue(IrToBitcode.kt)
            at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor$InnerScope.genGetValue(IrToBitcode.kt)
            at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor$InnerScope.genGetValue(IrToBitcode.kt)
            at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor$InnerScope.genGetValue(IrToBitcode.kt)
            at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor$InnerScope.genGetValue(IrToBitcode.kt)
            at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor$ParameterScope.genGetValue(IrToBitcode.kt:621)
    3 replies · 1 participant
  • m

    Mikołaj Kąkol

    01/25/2021, 4:25 PM
    class AppSession internal constructor(globalScope: GlobalScope) {
    
        private val appRepositoryFactory = globalScope.appRepositoryFactory
    
        init {
            CoroutineScope(Dispatchers.Default).launch {
                withContext(Dispatchers.Default) {
                    appRepositoryFactory.profilesRepository
                }
            }
        }
    this is not
    class AppSession internal constructor(globalScope: GlobalScope) {
    
        init {
            CoroutineScope(Dispatchers.Default).launch {
                withContext(Dispatchers.Default) {
                    globalScope.appRepositoryFactory.profilesRepository
                }
            }
        }
    did someone had something weird? nothing is happening inside this “profilesRepository”. Without coroutines it also works. Error is:
    Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen pl.app.di.AppSession@848e28
        at 0   MobileBankShared                    0x0000000110718fcd kfun:kotlin.Throwable#<init>(kotlin.String?){} + 93 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Throwable.kt:23:37)
    a
    3 replies · 2 participants
  • n

    Nicholas Tian

    01/29/2021, 12:39 AM
    Hi there, I am wondering. Is there a way to build an iOS framework with Kotlin and Swift mixed together? I am hoping to build a Kotlin core library/framework that I can share between my iOS and Android framework. But not sure how or even this is possible to work out. My preliminary research on the internet returned nothing much...
    c
    s
    5 replies · 3 participants
  • a

    aleksey.tomin

    01/29/2021, 11:41 AM
    I’ve written macOS application by kotlin-native. If I install the application from standard path -
    /Applications/myapp.app/Contents/MacOS/myapp.kexe
    - I see blurred image (see the first image). If I move
    /Applications/myapp.app
    into home and run
    ~/myapp.app/Contents/MacOS/myapp.kexe
    - I see the same. If I rename
    ~/myapp.app
    to
    ~/myapp
    and run
    ~/myapp/Contents/MacOS/myapp.kexe
    - I see ok image (see the second image) What do I wrong? How can I fix it?
    e
    2 replies · 2 participants
  • n

    napperley

    01/30/2021, 4:18 AM
    Where is KonanTarget located? Is KonanTarget a enum?
    m
    4 replies · 2 participants
  • m

    Michal Klimczak

    01/30/2021, 2:59 PM
    I noticed that when I expose a generic type from Kotlin Native to Swift, it's always nullable. E.g.
    MyCoolGenericExample<T>
    accessed from Swift will always have the
    T
    nullable. Is that true or am I missing something?
    1 reply · 1 participant
  • t

    Todd

    02/01/2021, 2:37 AM
    Is there something obviously wrong here that I'm missing? I always get
    Unfinished workers detected, 1 workers leaked!
    when running this code on linuxX64
    Untitled
    n
    l
    5 replies · 3 participants
  • j

    joshshin

    02/02/2021, 6:04 PM
    hi all, question about crash/error reporting. How do i get the proper dsym files for the shared module? Added this to the gradle file of the shared module:
    kotlin{
      targets.withType<KotlinNativeTarget> {
        binaries.all {
          freeCompilerArgs += "-Xadd-light-debug=enable"
        }
        binaries.withType<org.jetbrains.kotlin.gradle.plugin.mpp.Framework> {
          isStatic = true
        }
      }
    }
    I just hooked up my app to sentry and was testing things out, I see that I uploaded the dsym files, but everything's looking like this:
    k
    p
    11 replies · 3 participants
  • j

    John O'Reilly

    02/04/2021, 5:07 PM
    What's the current plans for being able to provide binary compatibility between versions of Kotlin.....I believe it's still case that for example with 1.4.30 release all libraries (that support kotlin/native ) will need to be updated?
    k
    r
    +1
    3 replies · 4 participants
  • j

    Jeff Lockhart

    02/05/2021, 6:02 AM
    How do you convert
    ByteArray
    to and from
    CFDataRef
    ? I found this for converting to/from
    NSData
    , but having a hard time figuring out how to do something similar for
    CFDataRef
    . I need to create a
    SecCertificateRef
    , which I’m using
    SecCertificateCreateWithData()
    and
    SecCertificateCopyData()
    to create and get the data from.
    3 replies · 1 participant
  • d

    Daniel Sapozhnikov

    02/05/2021, 10:07 AM
    Hello, I'm trying to call the
    hashCode
    function from my KMP project targeting jvm js and ios. The function provided by the kotlin-stdlib and kotlin-stdlib-js return the same results for a given
    String
    , however, the function provided by the Kotlin/Native stdlib (which seems to call
    Any.identityHashCode()
    under the covers) returns different results for the same
    String
    . Does anyone know if this is intentional and whether there might be a way to get results from the Kotlin/Native target that are consistent with the other targets?
    a
    2 replies · 2 participants
Powered by Linen
Title
d

Daniel Sapozhnikov

02/05/2021, 10:07 AM
Hello, I'm trying to call the
hashCode
function from my KMP project targeting jvm js and ios. The function provided by the kotlin-stdlib and kotlin-stdlib-js return the same results for a given
String
, however, the function provided by the Kotlin/Native stdlib (which seems to call
Any.identityHashCode()
under the covers) returns different results for the same
String
. Does anyone know if this is intentional and whether there might be a way to get results from the Kotlin/Native target that are consistent with the other targets?
a

Artyom Degtyarev [JB]

02/05/2021, 2:01 PM
I’m not sure if Kotlin Multiplatform have any guarantees here, but it seems to be a valid concern, so worth a report. Please consider filing an issue here: kotl.in/issue
d

Daniel Sapozhnikov

02/08/2021, 5:39 PM
Tracked here
View count: 2