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
  • p

    Patrick

    11/18/2019, 2:18 PM
    I am using version 1.3.50
    k
    • 2
    • 52
  • j

    JoakimForslund

    11/18/2019, 2:45 PM
    Which collection type in kotlin is considered to be the most performant? Things to be considdering is that it should handle a lot add and a lot of deletes. Is there even such a collection, that tries to as performant as it could possibly be?
    d
    p
    +2
    • 5
    • 8
  • k

    Kris Wong

    11/18/2019, 7:59 PM
    oh man - it looks like in order to update my kotlin version in my multiplatform project, any deps I am using that support K/N also need to be built with the latest?
    :yes: 4
    a
    s
    +2
    • 5
    • 7
  • m

    Marc Reichelt

    11/18/2019, 8:42 PM
    Hi there! I just tried to upgrade Kotlin to 1.3.60 for my talk tomorrow, but it seems to miss ktor and kotlinx serialization dependencies:
    > Task :SharedCode:compileKotlinIos FAILED
    w: skipping /Users/mreichelt/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-serialization-iosx64/1.2.5/3b67cda81d91ebb007b5d22aae904569cb794108/ktor-client-serialization.klib. The abi versions don't match. Expected '[17]', found '14'
    w: The compiler versions don't match either. Expected '[]', found '1.3.50-release-11850'
    e: Could not find "/Users/mreichelt/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-serialization-iosx64/1.2.5/3b67cda81d91ebb007b5d22aae904569cb794108/ktor-client-serialization.klib" in [/Users/mreichelt/Entwicklung/other/github-api-kotlin-multiplatform/android, /Users/mreichelt/.konan/klib, /Users/mreichelt/.konan/kotlin-native-macos-1.3.60/klib/common, /Users/mreichelt/.konan/kotlin-native-macos-1.3.60/klib/platform/ios_x64].
    
    FAILURE: Build failed with an exception.
    What are the latest dependencies to use for Kotlin 1.3.60? Or is it just too fresh yet?
    s
    k
    • 3
    • 4
  • k

    Kris Wong

    11/18/2019, 9:57 PM
    I updated my Kotlin IDE plugin, without updating my project's kotlin version, and that seems to be causing some issues with K/N
    p
    j
    • 3
    • 5
  • p

    Patrick

    11/19/2019, 12:05 PM
    Does the IntelliJ Idea Debugger work with Kotlin Native unit tests or do I have to use the command line debugger?
    j
    • 2
    • 6
  • f

    Fail

    11/19/2019, 1:10 PM
    Hi everybody! Can I draw over screen with kotlin-native on linux or macOs? For example draw a text.
    o
    n
    • 3
    • 3
  • r

    ribesg

    11/19/2019, 2:06 PM
    Just by updating Gradle from 5.x to 6.0.1 I get this:
    Caused by: java.lang.NoSuchMethodError: org.jetbrains.kotlin.gradle.tasks.CInteropProcess.newOutputFile()Lorg/gradle/api/file/RegularFileProperty;
    I’m using Kotlin 1.3.50. Should I wait for an update of the Kotlin plugin for Gradle 6 or something?
    b
    • 2
    • 2
  • r

    Robert

    11/19/2019, 7:45 PM
    Could someone advice this newbee? I have this C*++* project I am trying to migrate to Kotlin (has dependencies too). I tried to write it all from scratch, but came to the conclusion that's not the right way, too much errors, to much to code before I can verify/test etc. So I decided to compile Kotlin to a dynamic C-library and load it into C*++* (as described here https://kotlinlang.org/docs/tutorials/native/dynamic-libraries.html). This works 👍 This way I can migrate one part of the C*++* project at the time. Q: Problem is that I have to migrate ALL types that are being mentioned in the part of code I want to migrate, as see now way to reference the C*++* types from Kotlin. Is there a way to reference the C*++* types from within Kotlin and compile it to C?
    d
    • 2
    • 5
  • k

    Kris Wong

    11/19/2019, 7:57 PM
    I am hitting this
    ThrowWorkerInvalidState()
    with 1.3.60, did not happen with 1.3.50
    Worker.cpp
    o
    • 2
    • 4
  • t

    tylerwilson

    11/19/2019, 8:10 PM
    Anybody else see crashes in Xcode when breakpoints are set and using a Kotlin MPP framework. Not breakpoints in the Kotlin code, just in the ObjC/Swift code. If I unset the breakpoints and run again, it is fine.
    k
    t
    a
    • 4
    • 49
  • k

    Kris Wong

    11/19/2019, 8:13 PM
    Task :linkDebugFrameworkIos
    warning: linking module flags 'SDK Version': IDs have conflicting values ('[2 x i32] [i32 13, i32 0]' from /Users/krisw/.konan/kotlin-native-macos-1.3.60/konan/targets/ios_x64/native/debug.bc with '[2 x i32] [i32 13, i32 2]' from out) warning: linking module flags 'SDK Version': IDs have conflicting values ('[2 x i32] [i32 13, i32 0]' from /Users/krisw/.konan/kotlin-native-macos-1.3.60/konan/targets/ios_x64/native/strict.bc with '[2 x i32] [i32 13, i32 2]' from out) warning: linking module flags 'SDK Version': IDs have conflicting values ('[2 x i32] [i32 13, i32 0]' from /Users/krisw/.konan/kotlin-native-macos-1.3.60/klib/common/stdlib/targets/ios_x64/native/runtime.bc with '[2 x i32] [i32 13, i32 2]' from out) warning: linking module flags 'SDK Version': IDs have conflicting values ('[2 x i32] [i32 13, i32 0]' from /Users/krisw/.konan/kotlin-native-macos-1.3.60/klib/platform/ios_x64/posix/targets/ios_x64/native/cstubs.bc with '[2 x i32] [i32 13, i32 2]' from out) warning: linking module flags 'SDK Version': IDs have conflicting values ('[2 x i32] [i32 13, i32 0]' from /Users/krisw/.konan/kotlin-native-macos-1.3.60/klib/platform/ios_x64/Foundation/targets/ios_x64/native/cstubs.bc with '[2 x i32] [i32 13, i32 2]' from out)
    k
    r
    +3
    • 6
    • 18
  • b

    basher

    11/20/2019, 6:45 PM
    Will there be an official 1.3.60 K/N release here: https://github.com/JetBrains/kotlin-native/releases ? I usually wait for that and/or an announcement here from the K/N folks before I start releasing upgraded libraries
    k
    d
    +2
    • 5
    • 10
  • r

    Robert

    11/20/2019, 9:49 PM
    I am trying to migrate C++ code by compiling Kotlin to a dynamic library and replacing step by step. I load this lib by including the header and the symbols:
    #include "libmy_api.h"
    auto mylib = libmy_symbols();
    So far so good. Now I would love to replace the orginal classes, for example
    CMyClass
    with the one from the Kotlin library. So I remove
    CMyClass
    from the C-source code, and I add a typedef:
    typedef libmy_kref_MyClass MyClass;
    Now I can use the regular
    MyClass
    as a type:
    std::vector<MyClass> classes
    So I don't have to touch that code, as it was already referencing "MyClass". Still good. Now the problem is when I try to create an instance. The current code is like this:
    classes.push_back(MyClass())
    But to initiate the class in the KN dl way, I have to replace all the code with:
    classes.push_back(mylib->kotlin.root.MyClass.MyClass())
    Is there a way, like typedef or using does, to keep this code intact while it does actually reference the kotlin generated dynamic library?
    o
    y
    • 3
    • 13
  • j

    Jamie Craane

    11/21/2019, 7:17 PM
    I have an existing Android project which I am migrating to K/N. First thing is to move the domain object layer to the K/N common module so the the to-be developed iOS can already start using this code. This approach seems to work. I have replaced a third-party DateTime library with the K/N Klock library (https://github.com/korlibs/klock). The existing Android app uses Java serialization to pass objects between activities. I created A an expect interface KSerializable with an actual typealias to Serializable in the Android source tree. This works, domain objects in the common can now be serialized using Java serialization in the Android app. The Klock DateTime object is, however, not serializable. this class does not implement KSerializable. Is there an approach to use Java serialization mechanism without much rewrite (this mechanism (passing serialized objects to activities) is used a lot in this application)? A possible solution could be creating Parcelable and pass the data as Parcelable, perhaps use a Json representation as the Parcelable object (using readString and writeString). Thanks!
    😎 1
    a
    e
    s
    • 4
    • 6
  • j

    jk2018

    11/21/2019, 10:34 PM
    Just playing around with Kotlin native ( building a windows exe for starters). I'm trying to read individual keystrokes, and can't seem to figure out how. Where to look?
    o
    • 2
    • 4
  • i

    ivan.savytskyi

    11/22/2019, 2:32 PM
    am I right that there is no official release of coroutines for 1.3.60 Kotlin? Kotlinx coroutines 1.3.2 is still on 1.3.50 Kotlin release?
    m
    • 2
    • 2
  • s

    serebit

    11/22/2019, 4:12 PM
    I'm the maintainer of the kotlin-native distribution on Solus (a Linux distribution). The
    v1.3.60
    tagged release is failing to build for me, but the later tag
    v1.3.60-release-13393
    builds successfully. Are there any substantial differences between the two?
    😱 1
    o
    • 2
    • 2
  • v

    Vincent Chen

    11/24/2019, 11:30 AM
    Hi, I have two questions, I don’t know they are about gradle or K/N My build.gadle.kts
    import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
    
    
    plugins {
        id("org.jetbrains.kotlin.multiplatform") version "1.3.60"
    }
    
    repositories {
        mavenCentral()
    }
    
    kotlin {
        ....
    }
    
    tasks.getByName("assemble")!!.finalizedBy("android_A")
    tasks.getByName("assemble")!!.finalizedBy("IOS_A")
    tasks.getByName("assemble")!!.finalizedBy("JVM_A")
    
    tasks.create("android_A", Copy::class){
    
    }
    
    tasks.create("IOS_A", Copy::class){
    
    }
    
    tasks.create("IOS_B", FatFrameworkTask::class){
    
    }
    
    tasks.create("JVM_A", Copy::class){
    
    }
    This is fine and no warning But I want to spread platform, so I create folder
    app
    --spreadGradle
    ----android.gradle.kts
    ----ios.gradle.kts
    ----jvm.gradle.kts
    then My build.gradle.kts is
    plugins {
        id("org.jetbrains.kotlin.multiplatform") version "1.3.60"
    }
    
    repositories {
        mavenCentral()
    }
    
    apply(from = "spreadGradle/android.gradle.kts")
    apply(from = "spreadGradle/ios.gradle.kts")
    apply(from = "spreadGradle/jvm.gradle.kts")
    
    kotlin {
        ....
    }
    
    tasks.getByName("assemble")!!.finalizedBy("android_A")
    tasks.getByName("assemble")!!.finalizedBy("IOS_A")
    tasks.getByName("assemble")!!.finalizedBy("JVM_A")
    and android.gradle.kts is
    tasks.create("android_A", Copy::class){
    
    }
    ios.gradle.kts is
    import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
    
    tasks.create("IOS_A", Copy::class){
    
    }
    
    tasks.create("IOS_B", FatFrameworkTask::class){
    
    }
    jvm.gradle.kts is
    tasks.create("JVM_A", Copy::class){
    
    }
    But got two issuss First: although build is ok but got warning like
    Cannot add task 'android_A' as a task with that name already exists.
    Cannot add task 'JVM_A' as a task with that name already exists.
    etc. Second: in my ios.gradle.kts Error for
    unresolved reference: jetbrains
    Can master help me? Thank you very much
    d
    • 2
    • 1
  • j

    Jurriaan Mous

    11/24/2019, 12:39 PM
    How can I publish a native dependency as klib with the static library (a) included? For context the current build script: https://github.com/marykdb/rocksdb/blob/feature/native-implementation/build.gradle.kts The current published results: https://bintray.com/maryk/maven/RocksDB/0.3.0#files/io/maryk/rocksdb
    m
    p
    • 3
    • 9
  • n

    napperley

    11/24/2019, 10:47 PM
    Have a weird situation where the same text is repeated when printing a Kotlin String, eg:
    ./jmonitor.kexe --io-metrics Main
    I/O metrics for Main:
    * Characters Read: 1142215787
    * Characters Written: 2559364802
    * Total Read System Calls: 229852
    * Total Write System Calls: 148106
    * Total Bytes Read: 533704704
    * Total Bytes Written: 1415086080
    * cancelled_Total Bytes Written: 12288
    Note that
    Total Bytes Written
    is repeated twice. What could cause text to be repeated in a Kotlin String?
    m
    • 2
    • 5
  • a

    Andreas Jost

    11/25/2019, 10:24 AM
    Hey all, can anybody help me, how to add a GestureRecognizer to a UIView from Kotlin? I'm trying to achieve the ability to start a function (passed as a lambda), when a View is pressed. Here is what I tried: (ViewContainer is a typealias for UIView, I want to use this in the common presenter of an Android/iOS-Multiplatform project)
    actual fun ViewContainer.setOnCLickListener(block: () -> Unit) {
        val funRef = StableRef.create(InvokeClickListener(block))
    
        this.addGestureRecognizer(UITapGestureRecognizer(this, funRef.asCPointer()))
    }
    
    class InvokeClickListener(private val block: () -> Unit) : () -> Unit {
        override operator fun invoke() {
            block()
        }
    }
    I already managed to set the visibility of Views in the common code. If interested I can post code snippets in the multiplatform channel. But this case is harder, because UITapGestureRecognizer wants a selector/COpaquePointer and I can't find a solution.
    s
    • 2
    • 1
  • p

    Prateek Grover

    11/25/2019, 12:45 PM
    Hey all, getting the following error after updating to kotlin 1.3.60 with kotlin coroutines version 1.3.2-native-mt-1. I am building using module stitching as mentioned here https://github.com/JetBrains/kotlin-native/issues/3461#issuecomment-541937515. If I am not doing module stitching, the error does not appear. Have tried by checking that all versions are in sync but I do not feel thats the problem because if that was the case, it should have failed when not using module stitching. https://scans.gradle.com/s/wsiacoaizlniq Any idea about it?
    • 1
    • 2
  • s

    saket

    11/26/2019, 3:33 AM
    I just realized that I can't create an in-memory database using SqlDelight for writing unit tests. How are folks writing tests that talk to a storage layer?
    r
    • 2
    • 6
  • a

    andreasmattsson

    11/26/2019, 12:58 PM
    How do I access the
    values
    array of a Kotlin enum class from Swift/ObjC?
    a
    • 2
    • 4
  • n

    New111

    11/26/2019, 10:10 PM
    Hello, what is the kotlin-native to way to execute another jar (it is not fork !) and then depending on an action restart it or kill it ?
    s
    • 2
    • 4
  • j

    jk2018

    11/27/2019, 12:37 AM
    are there any libraries that work on all MP platforms?
    n
    • 2
    • 1
  • j

    jk2018

    11/27/2019, 12:37 AM
    i got that one to work just now, but was wondering if that only works bc it's bundled?
    j
    • 2
    • 19
  • n

    New111

    11/27/2019, 7:33 AM
    Hello all, what is the kotlin-native way to stop/kill another process ?
    a
    e
    +2
    • 5
    • 15
  • a

    alec

    11/27/2019, 11:04 PM
    does the KN cycle collector run asynchronously or synchronously once there have been
    GC.thresholdAllocations
    allocations?
    o
    e
    n
    • 4
    • 4
Powered by Linen
Title
a

alec

11/27/2019, 11:04 PM
does the KN cycle collector run asynchronously or synchronously once there have been
GC.thresholdAllocations
allocations?
o

olonho

11/28/2019, 5:52 AM
synchronously in the current thread, other threads are unaffected
e

EvaS

11/28/2019, 8:58 AM
Same topic, When does it run ?
o

olonho

11/28/2019, 11:06 AM
When certain heuristics trigger, it is not specified, and can change
n

napperley

11/28/2019, 10:47 PM
More documentation is needed on the cyclic collector.
View count: 2