https://kotlinlang.org logo
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
  • m

    Michael Bryant

    03/15/2019, 8:03 PM
    is there any documentation on using the kotlin
    List
    type (and other types from the
    collections
    package) in dynamic libraries? the generated headers indicate that a
    <pkg>_kref_kotlin_collections_List
    type is being used, but I can’t find any docs on it
    d
    r
    o
    • 4
    • 20
  • i

    ivan.savytskyi

    03/15/2019, 9:33 PM
    [KN / iOS] Question regarding the worker and memory leaks, I have a small test (not a unit test but rather screen with one button) that reads 500 times 1.2Mb text file into the memory via worker. I see after worker terminated the memory released but not to the previous level (before test started) but +500Kb. Every time I repeat this exercise I see +500Kb increase after every test. I’m not really sure if that Xcode Instruments misrepresents the memory or there is some leaks inside the KN runtime.
    val worker = Worker.start()
            worker.execute(
                mode = TransferMode.SAFE,
                producer = { { operation() }.freeze() },
                job = {
                    it()
                }
            )
            worker.requestTermination()
    To read from file
    NSString.stringWithContentsOfURL(url = file, encoding = NSUTF8StringEncoding, error = null)
    b
    o
    • 3
    • 9
  • g

    gmaciel

    03/16/2019, 12:37 PM
    Hi, i'm getting a
    Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen
    on ios, for trying to change the value of this var:
    object MyObject {
        var myVar: Boolean = false
    }
    d
    • 2
    • 3
  • g

    gmaciel

    03/16/2019, 12:37 PM
    is this expected? On Android i can the change the value without any issue.
    g
    • 2
    • 1
  • s

    Strum355

    03/16/2019, 3:02 PM
    Can i use kotlin native so that i can end up with a native binary instead of a jar file while also having data structures like arraylist available?
    g
    o
    s
    • 4
    • 6
  • l

    louiscad

    03/17/2019, 1:52 PM
    Hi, I'm looking for an example macOS project made with Kotlin/Native, where can I find one?
    g
    o
    • 3
    • 9
  • a

    Alexander Suslov

    03/17/2019, 2:17 PM
    Hi! I've migrated to the new MPP plugin. The project is an iOs/Android app. It works fine on my macbook, but when I try to compile Android app on my linux system, I receive a error:
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':adsmodule:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug'.
    > java.lang.RuntimeException: java.util.zip.ZipException: duplicate entry: ru/subprogram/guitarsongs/ads/BannerAdFactory.class
    Duplicate entry could be different after clean/rebuild. I use IDEA Ultimate 2018.3.5, tested kotlin version
    1.3.21
    and
    1.3.30-eap-45
    .
    l
    s
    • 3
    • 10
  • b

    basher

    03/18/2019, 5:34 PM
    Does K/N initialize all globals on the main thread during runtime init? (for native, specifically)
    d
    o
    • 3
    • 3
  • b

    basher

    03/18/2019, 7:52 PM
    Is there a way to create a non-capturing lambda for use with a Worker that isn't just providing the lambda in-line at the Worker.execute callsite?
    k
    s
    • 3
    • 5
  • b

    basher

    03/18/2019, 10:17 PM
    Do you have to freeze the objects stored in variables marked
    @SharedImmutable
    ?
    d
    • 2
    • 3
  • y

    yusuf3000

    03/19/2019, 1:57 PM
    Is
    import kotlinx.coroutines.newSingleThreadContext
    available in
    kotlinx-coroutines-core-common
    ? I can’t see any information here: https://github.com/Kotlin/kotlinx.coroutines/tree/master/common/kotlinx-coroutines-core-common But I can see it’s available for `kotlinx-coroutines-core`: https://github.com/Kotlin/kotlinx.coroutines/blob/master/core/kotlinx-coroutines-core/README.md
    g
    • 2
    • 2
  • r

    ribesg

    03/20/2019, 10:49 AM
    Maybe someone here can help 🙂
    j
    a
    • 3
    • 9
  • e

    Ellen Shapiro

    03/20/2019, 5:09 PM
    Am I correct that if I’m doing database stuff for MPP for iOS + Android, my options are basically a) SQLDelight b) Write `expect class`es which talk to Room and Core Data
    k
    s
    s
    • 4
    • 26
  • p

    Philip_Touchlab

    03/20/2019, 6:41 PM
    Hi everyone. Is it possible to have a unit test in commonTest of a library module and run it in iOS test runner?
    k
    • 2
    • 3
  • t

    toomanyeduardos

    03/20/2019, 7:46 PM
    is there a preferred library/method to serialize network data into data classes? on android I would use GSON or Moshi, but those don't seem to work on CommonMain
    k
    • 2
    • 3
  • t

    toomanyeduardos

    03/20/2019, 8:26 PM
    sorry for my dumb questions, but i just got back into KN/multiplatform and things have changed a bit. I'm trying to figure out why the latest ktor doesnt have have support for the iOS client:
    Could not resolve io.ktor:ktor-client-ios:1.2.0-alpha-2
    there's a thread on ktor about it, but it hints to just dropping support for iOS. Also, my versions of kotlin and gradle seem to be out of date. What are the latest ones you're using?
    kotlin.code.style=official
    
    # gradle version
    gradle_version = 3.2.1
    
    # kotlin versions
    kotlin_version = 1.3.21
    kotlin_native_version = 1.3.11
    ktor_version = 1.2.0-alpha-2
    kotlinx_coroutines_version = 1.1.0
    thanks
    o
    k
    +3
    • 6
    • 36
  • a

    alexcouch

    03/21/2019, 7:05 AM
    I got this code from the weather function sample and I don't understand why it is throwing this error
    o
    • 2
    • 1
  • a

    alexcouch

    03/21/2019, 7:05 AM
    I have read all over the docs and the internet in general for help. Nothing.
    s
    • 2
    • 2
  • y

    yusuf3000

    03/21/2019, 7:51 AM
    Is it possible to create a
    CoroutineContext
    from iOS and inject that into a kotlin/native class?
    g
    s
    • 3
    • 11
  • b

    Benedict Pregler

    03/21/2019, 8:15 AM
    Hi, is there an ETA when the current Kotlin/Native Plugin for AppCode will be updated? https://plugins.jetbrains.com/plugin/10619-kotlin-native-for-appcode
    👍 1
    s
    • 2
    • 1
  • v

    Vyacheslav Karpukhin [JB]

    03/21/2019, 2:52 PM
    @Benedict Pregler The new build of the AppCode plugin has just been uploaded. You can create a new project from the templates and give it a try. Make sure to click the "Import gradle project" button when opening the project for the first time.
    🎉 10
    🍏 2
    r
    l
    • 3
    • 5
  • e

    Ethan R.

    03/21/2019, 4:06 PM
    Hello, i was compiling various kernel32 headers for use in a scoreboard memory-reading application in kotlin/native, and only one of them successfully made it into a klib. I've tried all the others out individually and it still doesn't seem to work for any of them. Here's my .def file:
    headers = memoryapi.h processthreadsapi.h winnt.h tlhelp32.h handleapi.h
    compilerOpts.win32 = "-IC:/Program Files (x86)/Windows Kits/8.1/Include/um/" "-IC:/Program Files (x86)/Windows Kits/8.1/Include/shared/"
    linkerOpts.win32 = "-LC:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/x86/kernel32.lib"
    Only tlhelp32.h makes it through. Am I doing something wrong or should i just wait it out for a newer version?
    o
    • 2
    • 14
  • b

    basher

    03/22/2019, 1:21 AM
    Does this change at all based on native compiled arch?
    o
    n
    • 3
    • 5
  • t

    Thomas

    03/22/2019, 5:04 PM
    I'm trying to use Firebase Objective C code in Kotlin. I added this to the "common" build.gradle:
    compilations.getByName("main") {
        val firebase by cinterops.creating {
            defFile("$projectDir/src/iOSMain/cinterop/firebase.def")
            val pods = "$projectDir/../ios/Pods"
            includeDirs(
                "$pods/FirebaseCore/Firebase/Core/Public"
            )
    
            compilerOpts("-F$pods/Firebase -F$pods/FirebaseCore")
            linkerOpts("-F$pods/Firebase -F$pods/FirebaseCore")
        }
    }
    And this is the
    firebase.def
    file:
    language = Objective-C
    headers = FirebaseCore.h
    When trying to edit the Kotlin code I have no issues importing the Firebase framework. But when compiling for iOS (packForXCode) I get this error:
    ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame
    Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_FIRApp", referenced from:
          objc-class-ref in combined.o
    ld: symbol(s) not found for architecture x86_64
    error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
    Does anyone know why this is happening? Is there something wrong in my configuration?
    k
    i
    j
    • 4
    • 21
  • a

    azeDevs

    03/22/2019, 8:55 PM
    https://kotlinlang.slack.com/archives/C3SGXARS6/p1553226323370100 In reference to the quoted post shown at the bottom of this one, I think I've gotten closer, but I may have incorrect syntax. Right now my
    build.gradle
    looks like this:
    plugins {
        id "kotlin-multiplatform" version "1.3.21"
    }
    
    repositories {
        mavenCentral()
    }
    
    kotlin {
        mingwX64("mingw") {
            compilations.main {
                outputKinds("executable")
                entryPoint "classes.main"
            }
        }
        sourceSets {
            mingwMain {
                dependencies {
                    implementation fileTree(include: ['*.klib'], dir: 'libs')
                }
    
            }
            mingwTest {}
        }
    }
    
    task runProgram {
        println("getLibsDirName = "+getLibsDirName())
        def buildType = "RELEASE" // Change to 'DEBUG' to run application with debug symbols.
        dependsOn kotlin.targets.mingw.compilations.main.linkTaskName("EXECUTABLE", buildType)
        doLast {
            def programFile = kotlin.targets.mingw.compilations.main.getBinary("EXECUTABLE", buildType)
            exec {
                executable programFile
                args ""
            }
        }
    }
    and my
    settings.gradle
    looks like this:
    pluginManagement {
        resolutionStrategy {
            eachPlugin {
                if (requested.id.id == "kotlin-multiplatform") {
                    useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}")
                }
            }
        }
    }
    rootProject.name = 'gearNet'
    includeBuild './src/libs'
    Any advice on how to get my project to recognize and implement
    ./src/libs/kwinhelp.klib
    within my project? Any advice or even a direction on where to look for an answer is very much appreciated.
    d
    • 2
    • 15
  • a

    alexcouch

    03/23/2019, 2:43 AM
    I'm trying to use the cinterop tool and it keeps saying that it can't find the headers I put in my .def file. The docs say they should be relative to the def file but no matter how I put the path to my headers, it still says that it can't find my headers. Am I supposed to put compiler/linker options? I don't see other examples doing so. The tool doesn't give much information about why it can't find the headers, just says it can't find them. My def file is just a single line of
    headers = include/hidapi.h
    .
    k
    d
    s
    • 4
    • 16
  • t

    Thomas

    03/24/2019, 2:59 PM
    Is is possible to edit Kotlin/Native code in AppCode with autocomplete? I opened the KotlinConf spinner project and it shows unresolved references for
    platform.*
    , but has no issues compiling. If I open the same project in IntelliJ IDEA or Android Studio I don't get these errors and there is autocomplete. This basically makes editing the Kotlin/Native code impossible in AppCode and I would need to use IntelliJ IDEA or Android Studio just for the Kotlin files.
    o
    s
    l
    • 4
    • 11
  • g

    gmaciel

    03/25/2019, 4:48 PM
    Hello, any suggestion on open a local
    .json
    file and parsing into a model for an android/ios library? I just saw for the parsing i could use
    kotlinx.serialization
    and for opening the file within the project? Any other
    kotlinx
    project?
    o
    • 2
    • 3
  • m

    mben

    03/25/2019, 6:37 PM
    interactor.login(trigram: trigram) is a kotlin native function My problem is when i reach that code i get a weird error illegal attempt to access non-shared login.LoginInteractor@16f8b08 from other thread Anyone can help?
    s
    • 2
    • 7
  • t

    toomanyeduardos

    03/26/2019, 2:36 AM
    do we know if there's an update on whether we can change the name of the xcode framework, from
    main.framework
    to something customizable? there's this bug reported: https://youtrack.jetbrains.com/issue/KT-28313 which is listed as fixed, but it doesn't seem to compile. i keep getting
    Could not find method binaries() for arguments KotlinNativeTargetPreset
    y
    j
    • 3
    • 13
Powered by Linen
Title
t

toomanyeduardos

03/26/2019, 2:36 AM
do we know if there's an update on whether we can change the name of the xcode framework, from
main.framework
to something customizable? there's this bug reported: https://youtrack.jetbrains.com/issue/KT-28313 which is listed as fixed, but it doesn't seem to compile. i keep getting
Could not find method binaries() for arguments KotlinNativeTargetPreset
y

yuya_horita

03/26/2019, 2:37 AM
You can.
t

toomanyeduardos

03/26/2019, 2:37 AM
awesome. would you mind helping out with how i can?
y

yuya_horita

03/26/2019, 2:38 AM
https://medium.com/quick-code/kotlin-native-ios-e6480299e02f
This article (mine 😆 ) will be helpful.
I defined it as
ios_framework_name
in gradle file.
t

toomanyeduardos

03/26/2019, 2:39 AM
ok, i'll take a read. thank you!
👍 1
hey, i think that works!
i need to test it on xcode now, but thank you so much!
y

yuya_horita

03/26/2019, 2:49 AM
nice.
packForXcode
needs to be updated, too. But I describe that in same article.
t

toomanyeduardos

03/26/2019, 2:51 AM
yeah, i got too excited and didnt read it first
👍 1
j

Jonas Bark

03/26/2019, 6:36 AM
https://github.com/JetBrains/kotlin-native/pull/2806
Looks like it's already merged and in the FAQ
View count: 3