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

    Fré Dumazy

    11/06/2018, 7:47 PM
    Hi everyone. I'm just diving into K/N for the first time and I was wondering if you have some tips or tutorials for creating a GUI desktop app any recommended libs or frameworks for GUIs on Linux?
    r
    • 2
    • 2
  • s

    Sam

    11/06/2018, 11:02 PM
    I'm dusting off some Kotlin/Native code I was toying with over the Summer. This code used to work but now I'm getting a compiler error.
    error: type mismatch: inferred type is ULong but int64_t /* = Long */ was expected
                    val time = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_MSEC)
    It doesn't like
    NSEC_PER_MSEC
    which is a constant defined in the darwin header. If I just put a literal number in its place it will work fine.
    t
    m
    o
    • 4
    • 5
  • k

    kpgalligan

    11/07/2018, 12:01 AM
    Does anybody know of a good way to run a specific test from the command line with the mpp? I had this working back in konan but not since
    o
    • 2
    • 4
  • j

    jkbbwr

    11/07/2018, 3:55 AM
    I don't know how to get intellij to let me use
    GlobalScope.launch
    kotlin {
        targets {
            // For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64
            // For Linux, preset should be changed to e.g. presets.linuxX64
            // For MacOS, preset should be changed to e.g. presets.macosX64
            fromPreset(presets.linuxX64, 'linux')
    
            configure([linux]) {
                compilations.main.outputKinds('DYNAMIC')
            }
        }
        sourceSets {
            // Note: To enable common source sets please comment out 'kotlin.import.noCommonSourceSets' property
            // in gradle.properties file and re-import your project in IDE.
            commonMain {
                dependencies {
                    api('org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.0.0')
                }
            }
            linuxMain {
    
            }
            linuxTest {
            }
        }
    }
    g
    s
    y
    • 4
    • 6
  • s

    Sangeet

    11/07/2018, 11:39 AM
    I have heard kotlin native is 2 way interoperable with objc. How to add objc dependency to kotlin native through gradle ?
    o
    • 2
    • 4
  • j

    Jaroslav

    11/07/2018, 12:59 PM
    Is it possible to catch kotlin exception in swift code? (kotlin part imported as a framework)
    t
    o
    +3
    • 6
    • 35
  • y

    yuya_horita

    11/07/2018, 5:12 PM
    Crash reporting to Crashlytics also failed in this case. This is a serius problem.
    s
    • 2
    • 2
  • n

    Nikita Kulikov

    11/08/2018, 8:04 AM
    What microcontrollers architecture does Kotlin support?
    m
    n
    • 3
    • 2
  • i

    Ivan

    11/08/2018, 3:30 PM
    is it possible to build kotlin/native android module into aar? someway create an library and distribute it over android projects?
    • 1
    • 1
  • h

    Hunter Breathat

    11/08/2018, 5:33 PM
    Hey does native have a graphics lib included? Or would we have to implement one I know there is Android but i don't think that it's possible to use cross platform
    🇳🇴 2
    o
    n
    • 3
    • 10
  • y

    yuya_horita

    11/09/2018, 4:31 AM
    Can I catch RuntimeExeption from @Throws kotlin function in Swift in the future?
    t
    s
    • 3
    • 4
  • a

    Alexander Suslov

    11/09/2018, 1:46 PM
    I'm trying to migrate K/N 0.9.2 -> 1.3.0. I use iOs CommonCrypto module for Sha256 calculation. I have a crypto.def file with this content:
    package = crypto
    headers = CommonCrypto/CommonDigest.h
    compilerOpts.ios = -I/opt/local/include
    In my .kt file I have
    import crypto.*
    line and I can use CC_SHA256 function. But when I tried to migrate to K/N 1.3.0 I had a
    Unresolved reference: CC_SHA256
    compile error. I know that 1.3.0 already have a
    CommonCrypto.def
    file, so I deleted my
    crypto.def
    file and replaced
    import crypto.*
    by
    import platform.CoreCrypto.*
    . Now I have no compile errors. But I have a linker error instead:
    ld: warning: directory not found for option '-L/opt/local/lib'
    ld: framework not found CommonCrypto
    error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
    Could anybody help me?
    o
    n
    t
    • 4
    • 9
  • r

    restorn

    11/10/2018, 9:06 PM
    Using the new multi-platform gradle plugin to build a MP module(android/JS/iOS) with grade 4.7 with metadata enabled. When I try to define cinterop for an objC/swift dependency (firebase-firestorm-ios) and have 'kotlinx-coroutines-core-native' as a dependency I get an error (only when defining cinterop): * What went wrong: Could not resolve all files for configuration ':common-all:iOSFirestoreCInterop'.
    Could not resolve org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.0.1.
    Required by: project :common-all > Unable to find a matching configuration of org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.0.1: - Configuration 'debugIos_arm32Link': - Found org.gradle.native.debuggable 'true' but wasn't required. - Found org.gradle.native.optimized 'false' but wasn't required. - Found org.gradle.status 'release' but wasn't required. - Required org.gradle.usage 'java-api' and found incompatible value 'kotlin-api'. - Required org.jetbrains.kotlin.native.target 'ios_arm64' and found incompatible value 'ios_arm32'. - Required org.jetbrains.kotlin.platform.type 'native' and found compatible value 'native'. - Configuration 'debugIos_arm64Link': - Found org.gradle.native.debuggable 'true' but wasn't required. - Found org.gradle.native.optimized 'false' but wasn't required. - Found org.gradle.status 'release' but wasn't required. - Required org.gradle.usage 'java-api' and found incompatible value 'kotlin-api'. - Required org.jetbrains.kotlin.native.target 'ios_arm64' and found compatible value 'ios_arm64'. - Required org.jetbrains.kotlin.platform.type 'native' and found compatible value 'native'. - Configuration 'debugIos_x64Link': - Found org.gradle.native.debuggable 'true' but wasn't required. - Found org.gradle.native.optimized 'false' but wasn't required. - Found org.gradle.status 'release' but wasn't required. - Required org.gradle.usage 'java-api' and found incompatible value 'kotlin-api'. - Required org.jetbrains.kotlin.native.target 'ios_arm64' and found incompatible value .... The build file can be found here: https://github.com/RubyLichtenstein/Kotlin-Multiplatform-Firebase/blob/ios/common-all/build.gradle Any ideas? I suppose since I was targeting 'iosArm64' that the correct configuration should have been 'debugIos_arm64Link' but there is a mismatch due to 'Required org.gradle.usage 'java-api' and found incompatible value 'kotlin-api''.
    i
    • 2
    • 2
  • h

    Hunter Breathat

    11/11/2018, 2:13 AM
    Do we have kotlin.text or is that purely on JVM portion
    l
    o
    • 3
    • 2
  • n

    napperley

    11/11/2018, 10:52 PM
    Is it possible to pass through an array of C pointers to a C function as a single parameter? There is a GTK function which appears to take a array of GtkWidget, here is the definition:
    public fun gtk_container_add(container: CValuesRef<GtkContainer>?, widget: CValuesRef<GtkWidget>?): Unit
    Would like to add multiple GTK widgets to a GTK container using a single function call. If three or more widgets need to be added to a container then it would be tedious to call the same function multiple times.
    o
    m
    • 3
    • 7
  • h

    Hunter Breathat

    11/12/2018, 3:29 PM
    Hey if anyone is interested I'm currently rewriting the Android UI for native as a Klib, just without the system hooks for Android you can find it on gitlab.com/nexishunter/kui if you wanna help or just PM me :)
    a
    • 2
    • 6
  • k

    kpgalligan

    11/12/2018, 8:02 PM
    Shared mutable data. This is interesting: https://github.com/JetBrains/kotlin-native/pull/2311. Curious what the plan is for that. The 'share' method is private, so very restricted access to shared mutable state?
    t
    • 2
    • 2
  • h

    Hunter Breathat

    11/13/2018, 1:11 AM
    So I'm having issue with the kotlin.text lib as most of the functions that are listed on the ref site don't actually allow you to call the ex ->
    :dusty_stick: 5
    r
    d
    • 3
    • 6
  • j

    Jonas Bark

    11/13/2018, 10:12 AM
    According to https://github.com/JetBrains/kotlin-native/blob/master/OBJC_INTEROP.md -> Function types every callback requires returning a KotlinUnit instance, like this:
    ApiExample().exampleRequest(machine: machine) { response, exception in
       return KotlinUnit()
    }
    When one wants to distribute a library to 3rd party devs requiring the dev to return a KotlinUnit on every callback has a bad smell attached to it. Is there any plans to change this behaviour?
    👍 2
    o
    s
    • 3
    • 3
  • m

    matej

    11/13/2018, 10:25 AM
    quick question, is there some stdlib equivalent to sleep or delay for kotlin native that doesn't require me to pull in coroutines?
    m
    o
    • 3
    • 3
  • m

    matej

    11/13/2018, 10:25 AM
    trying to play around with a raspberry pi zero, something like that would come in handy
    o
    • 2
    • 2
  • n

    nestserau

    11/13/2018, 2:15 PM
    I try to use
    kotlin-stdlib/kotlin.text/toByteArray
    in my multiplatform project with no luck. What’s the idea behind converting strings to bytes and vice versa? Should I write platform-specific code at this point?
    l
    • 2
    • 6
  • i

    Ivan

    11/13/2018, 2:18 PM
    Hi, how to combine
    kotlin-multiplatform
    and
    kotlin-android
    plugins inside
    build.gradle
    file? I really need to have
    kapt
    for room to work on android module, but I cant get
    kapt
    to work without
    kotlin-android
    plugin, which cannot be added because of error
    Cannot add extension with name 'kotlin', as there is an extension already registered with that name
    Project was created by intellij idea, it creates 1
    build.gradle
    for all platforms so I dont have android own 'build.gradle'
    d
    t
    • 3
    • 2
  • d

    drofwarcs

    11/13/2018, 9:19 PM
    Using cinterop to bring in an objc framework and one of the functions it generated is
    fun niceMockForClass(aClass: kotlinx.cinterop.ObjCClass?): kotlin.Any?
    . How do we get an instance of
    ObjCClass
    from an existing object or from a class type?
    s
    • 2
    • 2
  • p

    pajatopmr

    11/14/2018, 1:22 AM
    I am trying to build the hello world program for kotlin native on a macos system. I think the fact I am failing miserably is due to stale documentation. Basically, I tried both downloading from GitHub and using brew. Neither one has konan (is this still a thing?) or kotlinc-native whereas kotlinc -version advertises itself as kotlinc-jvm … Can someone supply a link for a newbie to Kotlin native to build a macos executable for hello world or some simple basic program.
    g
    o
    +3
    • 6
    • 24
  • p

    pajatopmr

    11/14/2018, 2:02 AM
    Is it the case that Kotlin/Native after 1.3.0 is now a part of kotlin-multiplatform and Gradle must be used to build an executable? Not that that is a bad thing, just more to learn before I can totally grok the moving pieces of a Kotlin/Native app.
    g
    m
    • 3
    • 17
  • d

    Dico

    11/14/2018, 2:38 AM
    Hello everyone. cinterop keeps throwing this exception (see thread) I'm trying to import glfw into my project. I tried various things but the error doesn't go away.
    • 1
    • 3
  • s

    Sangeet

    11/14/2018, 8:08 AM
    I was following the below article for creating
    multi-platform project
    https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html Can anyone help me to add
    kotlinx.serialization
    dependency to
    commonMain
    s
    t
    • 3
    • 6
  • y

    yuya_horita

    11/14/2018, 9:14 AM
    Hello everyone. Is it possible to use kotlinx/coroutine with background thread in the future ? I found the convesation in
    <https://github.com/Kotlin/kotlinx.coroutines/issues/462>
    , but I can’t get it in detail. (Only single thread will be supported and improved ?)
    t
    k
    +2
    • 5
    • 19
  • y

    yuya_horita

    11/14/2018, 9:16 AM
    I want to do http requesting with ktor in background thread. Multi-Thread is needed for iOS, isn’t it? Thank you 🙏
    k
    • 2
    • 3
Powered by Linen
Title
y

yuya_horita

11/14/2018, 9:16 AM
I want to do http requesting with ktor in background thread. Multi-Thread is needed for iOS, isn’t it? Thank you 🙏
k

kpgalligan

11/14/2018, 2:55 PM
Ktor concurrency is implemented with coroutines. Native coroutines are single threaded at the moment. Ktor does iOS networking with async calls, though, so it’ll suspend the main thread and will be ok in most cases, except maybe if you were loading huge files. You’d be processing the result on the main thread
y

yuya_horita

11/15/2018, 2:25 AM
Yes, thank you 🙏 But, I hope I can use coroutines with background thread in the future.
k

kpgalligan

11/15/2018, 5:18 AM
Same
😎 2
View count: 7