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

    GarouDan

    06/13/2020, 12:24 PM
    Hi, Do you know how to solve this problem?
    There are 132 libraries libraries from the Kotlin/Native 1.3.61 distribution attached to the project: stdlib, AVFoundation, AVKit, Accelerate, Accounts, ...  These libraries were compiled with an older Kotlin/Native compiler and can't be read in IDE. Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version 1.4-M2. Then re-import the project in IDE.
    I’m already using Kotlin
    1.4-M2
    but it looks like Kotlin/Native still keeps downloading this version. How can I force it to use
    1.4-M2
    ? I’m using Gradle with KTS
    a
    • 2
    • 6
  • g

    GarouDan

    06/13/2020, 10:21 PM
    Hi, Where can I find the definition of this function
    platform.posix.system(command)
    ? I’d like to get the output or the error, like we do with the inputStream and errorStream for jvm. I tried to find inside of the repo but it is difficult to locate it there
    m
    • 2
    • 2
  • a

    aleksey.tomin

    06/15/2020, 12:45 PM
    I have a public variable:
    @SharedImmutable
    var APPENDER: Appender = ConsoleOutputAppender
    And I have error
    kotlin.native.IncorrectDereferenceException: Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread
    ...
    at 6  app.kexe           0x00000001022aae84 kfun:mu.<get-APPENDER>()Appender + 100 (File.kt:10:1)
    on read this variable. But why?
    @SharedImmutable
    was added.
    e
    b
    k
    • 4
    • 24
  • j

    Justin

    06/15/2020, 8:00 PM
    I am getting this fatal error when trying to run iOS simulator tests for a Kotlin Multiplatform project:
    com.intellij.execution.ExecutionException: No configuration for executable=KonanExecutableBase(targetType=ios_x64, targetName=iOSSim, executableName=test, projectPrefix=:flowdriver:)
    	at com.jetbrains.mpp.debugger.GradleLLDBBackend.binaryConfiguration(GradleLLDBBackend.kt:21)
    	at com.jetbrains.mpp.debugger.GradleLLDBBackend.binaryConfiguration(GradleLLDBBackend.kt:16)
    	at com.jetbrains.mpp.debugger.LLDBBackendBase.debugConfigurationSettings(LLDBBackendBase.kt:95)
    	at com.intellij.openapi.externalSystem.service.execution.ForkedDebuggerThread.handleForkedProcessSignal(ForkedDebuggerThread.java:143)
    	at com.intellij.openapi.externalSystem.service.execution.ForkedDebuggerThread.run(ForkedDebuggerThread.java:102)
    Notably, when I tried to run these tests the first time, an Xcode dialog popped up asking for my password to give permission for
    xcrun
    (or something like that) and I accidentally clicked cancel and dismissed the prompt. Is it possible that I need to somehow reset that prompt so I can enter my password and fix this?
    k
    • 2
    • 3
  • n

    napperley

    06/16/2020, 1:47 AM
    What position is Kotlin Native currently at with performance guarantees (eg soft real time - https://blog.jetbrains.com/kotlin/2018/02/application-development-in-kotlinnative/ )? Which performance guarantees will Kotlin Native provide when it reaches 1.0 (aka stable)?
    s
    • 2
    • 5
  • m

    Mananpoddarm

    06/16/2020, 5:55 AM
    Hi, I have used cinterop for android in kotlin native successfully in the past but when now I try the same thing for windows, Kotlin native is not able to build it. I keep getting e: C:\Users\t-mapodd\.konan\dependencies\msys2-mingw-w64-x86_64-clang-llvm-lld-compiler_rt-8.0.1/bin/clang++ invocation reported errors I thought, that function definitions are not important in compile time and hence just with the header file it would build similar to what I did for android but it's not able to build without function definition it seems. Has anyone worked with cinterop in mingw(windows target) in kotlin native?
    a
    • 2
    • 7
  • v

    Vsevolod Ganin

    06/16/2020, 3:20 PM
    Hi! Are iOS’ nullable
    init
    s supported? As I can see, Kotlin interop nullable init methods are deprecated in favor of constructors but constructors cannot produce
    null
    , do they? Am I missing something? For example: https://developer.apple.com/documentation/foundation/nsurl/1413146-init
    • 1
    • 1
  • c

    Christian Sousa

    06/16/2020, 4:19 PM
    Hello! I’m trying to do something but I’m unable to right now, what I have is the following:
    private fun getDataFromUrl(url: NSURL) {
            NSURLSession.sharedSession.dataTaskWithURL(
                url = url,
                completionHandler = ::getCompletion.freeze()
            ).resume()
        }
    So with this, I will get data from a URL After that, with my getCompletion
    fun getCompletion(data: NSData?, response: NSURLResponse?, error: NSError?){
        var downloadedImage = UIImage(data = data)
        logo.setImage(image = downloadedImage)
        logo.setHidden(false)
    }
    Where my logo is a UIImage. Problem is, the
    getCompletion
    is being called from a background thread and I’m trying to update something on the main thread. Is there any way of doing this? The goal is to be able to download the image asynchronously and after that, update the image I already have. What I’m getting as an error is the following:
    Main Thread Checker: UI API called on a background thread: -[UIImageView setImage:]
    s
    • 2
    • 3
  • d

    Derek Ellis

    06/16/2020, 4:21 PM
    Has anyone ever gotten an "Initializer is not implemented" error when trying to subclass an Obj-C class?
    a
    • 2
    • 3
  • m

    Mananpoddarm

    06/16/2020, 5:46 PM
    Hi everyone. I have successfully built .dll using kotlin multiplatform. I am using these .dll in my windows console app(using visual studio as IDE, I am not sure if that's important). when I am calling a function from my console app which is returning 8 a/c to KMP, it's printing some gibberish like 123453245 instead of 8. Has anyone faced the same issue, can anyone help me here? I think, the way I am calling it is forcing KMP to return pointer. Is there any documentation which suggests how to call functions written in header files generated by KMP in a windows app?
    a
    • 2
    • 1
  • d

    Draget

    06/16/2020, 8:04 PM
    Kotlin collections are based on Java collections, according to the documentation. What does this mean for collections in Kotlin/Native? Are the simply 'not available'? And if yes, what is the future plan for this?
    t
    s
    • 3
    • 5
  • a

    aleksey.tomin

    06/17/2020, 4:51 AM
    What I need to use in worker instead of
    sleep
    ?
    Worker.start().execute(TransferMode.SAFE, {}) {
      ...
      ??? sleep(100u)
    }
    On MacOS
    sleep
    leads error
    flock failed to lock maps file: errno = 35
    delay
    doesn’t allowed out of coroutine.
    a
    • 2
    • 4
  • b

    basher

    06/17/2020, 7:15 PM
    fileUrlWithPath takes a path that starts with
    /
    a
    • 2
    • 3
  • d

    dazza5000

    06/18/2020, 12:06 AM
    does anyone have an example handy of accessing kotlin native from python?
    r
    • 2
    • 7
  • m

    Mananpoddarm

    06/18/2020, 5:42 AM
    Hi everyone.
    TfLiteTensorCopyFromBuffer(input_tensor, inputs as CValuesRef<*>, inputs.size as ULong)
    "inputs" is of type Array<Any>. I want to extract the data from this "inputs" and feed it to tensorflow function(I am using cinterop to access tensorflow C API) but in runtime it throws me error as Array<Any> cannot be typecasted to CValuesRef<*>. I am asssuming there must be some function like "inputs.data" or something which can do the job. could anyone help me here please?
    a
    • 2
    • 7
  • a

    aleksey.tomin

    06/18/2020, 7:32 AM
    Hi I have problems with Info.plist in MacOS application. My app must to get GPS information. I call
    CLLocationManager.requestAlwaysAuthorization
    on start. It works from IDEA or command line. But when I make PKG file by this and create Info.plist file. If I add into file
    <key>NSLocationUsageDescription</key>
        <string>My information</string>
    application doesn’t use message, ask me any time, write info console the error
    app.kexe[31495:7080886] There was an error parsing the Info.plist for the bundle at URL <....>: NSCocoaErrorDomain - 3840
    and CAN’T get gps info. If I add into file
    <key>NSLocationAlwaysUsageDescription</key>
    application ask me ONE time, write info console the same error
    app.kexe[31495:7080886] There was an error parsing the Info.plist for the bundle at URL <....>: NSCocoaErrorDomain - 3840
    and GETS gps info. But Launchpad ignored my app 🤯 What have I to do?
    • 1
    • 1
  • t

    Tijl

    06/19/2020, 10:20 AM
    is there any Jetbrains IDE at the moment with a working Kotlin/Native debugger for macos or (preferably) iosX64 targets?
    a
    • 2
    • 3
  • m

    Mananpoddarm

    06/19/2020, 12:50 PM
    Hi everyone,
    headers = cinterop/c_interop/native/native.h
    linkerOpts.mingw = -Lwindows_x86_64/native.lib
    how should I put the relative path in headers(in windows.def file)? my directory structure is Intellligence/src/nativeInterop/cinterop/windows.def my build.gradle is in Intelligence/build.gradle
    a
    • 2
    • 2
  • k

    katokay

    06/20/2020, 5:29 PM
    Hi, I've been trying out the latest kotlin-coroutines 1.3.7-native-mt-1.4-M2 on iOS and running into some challenges. Code here is based on the flow documentation description for flowOn. https://kotlinlang.org/docs/reference/coroutines/flow.html I've also watched kotlinconf topic for kotlin native concurrency, so I understand objects are frozen, but for the life of me I can't figure out a combination that will allow me to set the value on StateFlow. I've tried numerous combinations and ultimately all paths throw the InvalidMutabilityException. Error occurs in the stateSetter call. Any help would be appreciated.
    typealias Reducer<TState> = (TState, Action) -> TState
    
    @OptIn(ExperimentalCoroutinesApi::class)
    open class KStore<TState:Any>(initialState: TState, private val reducer: Reducer<TState>) {
        private val state = MutableStateFlow(initialState)
    
        private fun currentState() = state.value
        private fun setState(newState: TState) {
            state.value = newState
        }
    
        fun dispatch(action: Action) {
            val currentGetter: () -> TState = ::currentState
            val stateSetter: (TState) -> Unit = ::setState
            val stateChanges = when(action) {
                is FlowAction -> action.toFlow()
                else -> flow { emit(action )}
            }.map {
                reducer(currentGetter(), it)
            }.flowOn(Dispatchers.Default)
            println("Got state changes")
            stateChanges.onEach {
                stateSetter(it)
            }.launchIn(UIScope())
        }
    
        //callback method for pushing back to swift, hopefully a better alternative can be found
        fun listen(onStateChange: (TState) -> Unit) = runBlocking {
            state.onEach {
                onStateChange(it)
            }.launchIn(UIScope())
        }
    }
    l
    e
    • 3
    • 8
  • m

    Mananpoddarm

    06/21/2020, 12:29 PM
    Hi everyone, I have two CPointers in kotlin( val voidPtr = stableRef.asCPointer()) does kotlin have an equivalent substitute of memcpy from C? How do I copy the contents from one pointer to another in kotlin?
    d
    n
    • 3
    • 6
  • c

    Chilli

    06/21/2020, 4:12 PM
    After updating Intellij Idea, dependencies don't resolve and the project doesn't compile.
    Gradle logs
    • 1
    • 1
  • o

    oshai

    06/22/2020, 9:33 AM
    Hi everyone, I will appreciate if someone with kotlin native experience can review this PR from @napperley https://github.com/MicroUtils/kotlin-logging/pull/119
    a
    • 2
    • 2
  • n

    natario1

    06/22/2020, 3:28 PM
    Is there a way to see symbols in the stack trace? I'm using
    NativeBuildType.DEBUG
    which I thought would do the job.
    I/Konan_main: Uncaught Kotlin exception: 
        kotlin.IllegalStateException: Test error!
    I/Konan_main:     at  (0x7e54f3d758) // ???
    I/Konan_main:     at  (0x7e54f37704) // ???
            at  (0x7e54f37374) // ???
            at  (0x7e54f37834) // ???
            at  (0x7e54fba8fc) // ???
            at  (0x7e54fc7538) // ???
            at  (0x7e54fb934c) // ???
            at  (0x7e54f935b8) // ???
            at  (0x7e54f91420) // ???
            at  (0x7e54fac57c) // ???
            at Java_my_package_my_method (0x7e54ff99b0)
            at oatexec (0x7e5541c720)
    a
    • 2
    • 3
  • a

    Arkadii Ivanov

    06/22/2020, 9:25 PM
    What is correct way to terminate a Worker? Or how currently running job can check if it's time to exit? Like Java's
    isInterrupted
    .
    r
    • 2
    • 2
  • j

    Jolas

    06/23/2020, 6:24 AM
    Is there any performance stats for Kotlin/Native framework against Swift IOS with SQLite queries? Attached is my sample stat for a simple select query(select * from table) for around 40 rows of data. First column - Kotlin/Native - 0.0.285 s | Second column - IOS Swift - 0.0116 (Note: SQLDelight Queries in Kotlin/Native and SQLite Framework queries Swift IOS). Some stats or suggestion on how to take stats and any pin points to known performance drawback would be enlightening.
    k
    a
    k
    • 4
    • 11
  • a

    Animesh Sahu

    06/23/2020, 12:05 PM
    Is there way to write JNI binding for Kotlin/JVM under Kotlin/Native (instead of C++)?
    r
    n
    +2
    • 5
    • 7
  • j

    John O'Reilly

    06/23/2020, 2:44 PM
    Has anyone tried running Kotlin/Native based project on macOS Big Sur Beta and XCode 12.0 beta? I'm getting following errors in XCode with that combination (Big Sur + XCode 11.5 is fine). It's probably expected there'd be issues but just in case anyone knows of any way to resolve....
    Undefined symbols for architecture x86_64:
      "_DAAddCallbackToSession", referenced from:
          _platform_DiskArbitration_DAAddCallbackToSession_wrapper10 in common(result.o)
         (maybe you meant: knifunptr_platform_DiskArbitration10_DAAddCallbackToSession, _platform_DiskArbitration_DAAddCallbackToSession_wrapper10 )
      "_DACallbackCreate", referenced from:
          _platform_DiskArbitration_DACallbackCreate_wrapper9 in common(result.o)
         (maybe you meant: knifunptr_platform_DiskArbitration9_DACallbackCreate, _platform_DiskArbitration_DACallbackCreate_wrapper9 )
      "_DAGetCallbackFromSession", referenced from:
          _platform_DiskArbitration_DAGetCallbackFromSession_wrapper13 in common(result.o)
         (maybe you meant: _platform_DiskArbitration_DAGetCallbackFromSession_wrapper13, knifunptr_platform_DiskArbitration13_DAGetCallbackFromSession )
      "_DARemoveCallbackFromSession", referenced from:
          _platform_DiskArbitration_DARemoveCallbackFromSession_wrapper12 in common(result.o)
         (maybe you meant: knifunptr_platform_DiskArbitration12_DARemoveCallbackFromSession, knifunptr_platform_DiskArbitration11_DARemoveCallbackFromSessionWithKey , _platform_DiskArbitration_DARemoveCallbackFromSessionWithKey_wrapper11 , _platform_DiskArbitration_DARemoveCallbackFromSession_wrapper12 )
      "_DARemoveCallbackFromSessionWithKey", referenced from:
          _platform_DiskArbitration_DARemoveCallbackFromSessionWithKey_wrapper11 in common(result.o)
         (maybe you meant: knifunptr_platform_DiskArbitration11_DARemoveCallbackFromSessionWithKey, _platform_DiskArbitration_DARemoveCallbackFromSessionWithKey_wrapper11 )
      "__kernelrpc_mach_port_destroy_trap", referenced from:
          _platform_darwin__kernelrpc_mach_port_destroy_trap_wrapper856 in common(result.o)
         (maybe you meant: _platform_darwin__kernelrpc_mach_port_destroy_trap_wrapper856, knifunptr_platform_darwin889__kernelrpc_mach_port_destroy_trap )
      "_objc_setHook_setAssociatedObject", referenced from:
          _platform_objc_objc_setHook_setAssociatedObject_wrapper100 in common(result.o)
         (maybe you meant: knifunptr_platform_objc100_objc_setHook_setAssociatedObject, _platform_objc_objc_setHook_setAssociatedObject_wrapper100 )
    • 1
    • 2
  • m

    Mananpoddarm

    06/23/2020, 4:31 PM
    Hi everyone, I have generated .dll using kotlin native for windows. I am able to access the functions from windows c++ console app as well(voila!) but I am not able to do the same for a c# windows app. [DllImport("libnative.dll", SetLastError = true)] public static extern void libnative_symbols()->kotlin.root.packagename.main(); I was able to call libnative_symbols()->kotlin.root.packagename.main(); from c++ windows console app but I am not able to call if from a c# app. could anyone redirect me to any example or resource?
    r
    • 2
    • 2
  • s

    spierce7

    06/23/2020, 6:49 PM
    How compatible is Kotlin with Swift Package Manager? My iOS team is talking about swapping over.
    s
    • 2
    • 1
  • d

    dazza5000

    06/23/2020, 7:06 PM
    What would be a good ui toolkit to use with kotlin MP on windows
    a
    • 2
    • 1
Powered by Linen
Title
d

dazza5000

06/23/2020, 7:06 PM
What would be a good ui toolkit to use with kotlin MP on windows
a

Andrew

06/24/2020, 5:31 AM
Depends if you want to build a UI in Java UI framework, JS or Native...
View count: 7