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

    spierce7

    07/09/2018, 10:39 PM
    Also, are there any examples for the atomic references being used? This is supposed to help with concurrency right?
    t
    o
    • 3
    • 4
  • s

    spierce7

    07/09/2018, 10:48 PM
    @olonho Are there any plans to make some of these Kotlin/native features compatible with other kotlin platforms? i.e. Workers, and thread local objects? I'd also be interested to know if there are any plans to opt-in to kotlin/native threading restrictions on other platforms. If it's better, I could see that being useful as well.
    t
    g
    o
    • 4
    • 5
  • t

    thymecypher

    07/10/2018, 2:08 AM
    Has anyone here built Kotlin from source? Curious how much disk space is needed, tried building Swift from source and with 62gb free, ran out of disk space :|
    o
    • 2
    • 1
  • m

    Mohit Gurumukhani

    07/10/2018, 3:01 AM
    Hi! I am trying to do http requests in Kotlin Native in ios jsing nsurlsession. I want to do it synchronously and so am using semaphores. However, when the callback for dataTaskWithRequest ends, I get a bad access error which according to the debugger, is caused due to garbage collection. Even when I comment out the first three lines of the callback lambda, I keep getting the error. Any help would be appreciated.
    fun call() : Unit{
    
        var url = NSURL.alloc()
        url = url?.initWithString("<https://jsonplaceholder.typicode.com/posts/1>")
        var nsrequest = NSMutableURLRequest(url as NSURL)
    
        nsrequest.HTTPMethod = "GET"
    
        var this_nsdata : NSData? = null
        var this_nsresponse : NSURLResponse? = null
        var this_nserror : NSError? = null
        var syncer = dispatch_semaphore_create(0)
    
        var sess = NSURLSession.sharedSession()
    
        var task = sess.dataTaskWithRequest(nsrequest) { nsdata: NSData?, nsresponse: NSURLResponse?, nserror: NSError? ->
            this_nsdata = nsdata
            this_nsresponse = nsresponse as NSHTTPURLResponse
            this_nserror = nserror
    
    
            dispatch_semaphore_signal(syncer)
        }
    
        task.resume()
    
        dispatch_semaphore_wait(syncer, DISPATCH_TIME_FOREVER)
    
        if(this_nserror == null && this_nsdata != null){
    
            this_nsresponse as NSHTTPURLResponse
            var nsstrobj = NSString.stringWithUTF8String(this_nsdata!!.bytes as CPointer<ByteVar>)
            print(nsstrobj as String)
        }
        else {
            print("whoops")
    
        }
    }
    o
    t
    s
    • 4
    • 11
  • m

    mcastiblanco

    07/10/2018, 7:00 AM
    I am trying to use
    org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.8
    but keep getting the error
    Could not find org.jetbrains.kotlin:kotlin-native-shared:0.8
    . Attaching full stack of the error...
    i
    • 2
    • 1
  • m

    musachev

    07/10/2018, 4:19 PM
    Hi guys! Noob question about running kotlin-native application via gradle-plugin(build). How can i add arguments for :run task so that they are caught in main method? Tried just adding it under configuration/arguments, and it's caught as task arguments 😞
    m
    • 2
    • 3
  • b

    bipin

    07/10/2018, 6:38 PM
    hey guys, can we use
    RxKotlin
    in
    Kotlin-Native
    common module?
    s
    k
    +2
    • 5
    • 21
  • y

    yusuf3000

    07/11/2018, 1:25 PM
    Jumping on Bipin’s post above: I want to call a method in kotlin native from iOS, which is going to call a method on an interface defined in kotlin and implemented on the iOS side. This method can perform a network call. Rather than the method in the interface using lambdas/closures, I want to use the
    suspend
    keyword. If you use the suspend keyword, then all methods that call this method also need to be marked with suspend. Which means that the method that is called from the iOS side is marked with suspend. But when I compile the kotlin framework using konan, the methods vanish from the Obj-c framework. Is this because coroutines are experimental? Will this be supported? I’ve got an example project where you can see this happening: https://github.com/yusufcareem/MockKNProject
    g
    b
    +2
    • 5
    • 10
  • s

    spierce7

    07/11/2018, 8:48 PM
    The K/N 0.8 blog post says:
    Other important JetBrains-provided libraries, like kotlinx.coroutines, kotlinx.serialization, and Ktor HTTP client are getting experimental Kotlin/Native support, which means it is possible to write an iOS app and Android application sharing the same REST API-related logic.
    I don't see kotlin/native access for these libraries. Do I need to access special branches? My team actually wants to start using the kotlin/native counterparts for all of these.
    👍 5
    t
    k
    +3
    • 6
    • 20
  • s

    Seri

    07/11/2018, 9:14 PM
    Wow, I wish I had your team!
    😕 1
    s
    • 2
    • 1
  • s

    spierce7

    07/12/2018, 2:58 AM
    I'm looking at the source code for the atomics. I think I must be confused about the way that frozen objects work:
    @Frozen
    class AtomicInt(private var value: Int = 0) {
      // ...
    }
    If you have a
    var
    in a frozen object, how can you still mutate the value of that
    var
    ? I thought it was unchangeable after it is frozen. What am I misunderstanding?
    o
    • 2
    • 4
  • b

    bipin

    07/12/2018, 7:07 AM
    guys, is there any library to use SharedPreference/UserDefaults in common? just like
    e5l/http-client-common
    t
    g
    r
    • 4
    • 4
  • b

    bipin

    07/12/2018, 7:48 AM
    Hi guys, I created
    awesome-kotlin-native
    repo, please contribute it to make curated list of mutliplatform libs, resources. https://github.com/bipinvaylu/awesome-kotlin-native
    👍 6
    n
    d
    r
    • 4
    • 6
  • a

    Aregev2

    07/12/2018, 8:31 AM
    How can I pass a Kotlin
    String
    to a C function?
    d
    o
    • 3
    • 3
  • d

    Dmitry Kandalov

    07/12/2018, 12:14 PM
    How can I map kotlin native stacktraces to kotlin source code? (Is there a tool for this?)
    o
    • 2
    • 1
  • e

    enleur

    07/12/2018, 2:02 PM
    no guice for kotlin/native? 😕
    g
    • 2
    • 3
  • l

    lsk

    07/12/2018, 3:22 PM
    Hi guys, can anybody help me with compiler error
    src/kotlin/main.kt:36:38: error: type _MDP_NOTIFY_TYPE is not supported in callback signature
    -> this probably meanas that I have too complex enum class as a parameter in the callback function. I want to know what’s not supported on the enum and if it is suppose to be fixed soon
    o
    • 2
    • 2
  • c

    caffeine

    07/12/2018, 10:42 PM
    Hello! I was broke the compiler of kotlin-native.
    object Foo {
        var counter = 0
    
        class Bar {
            init {
                //counter++// << this line
            }
        }
    }
    
    fun main(args: Array<String>) {
    //NOP
    }
    if delete "//" on marked line, then compiler throw exception
    o
    • 2
    • 1
  • d

    Dominaezzz

    07/13/2018, 6:39 PM
    Are IntArray and Array<Int> the exact same thing? Or is it same as Jvm backend?
    s
    • 2
    • 1
  • t

    thevery

    07/13/2018, 8:02 PM
    Hi guys! Is there are any good iOS+Android sample with MVP/UI?
    e
    k
    • 3
    • 4
  • m

    Mohit Gurumukhani

    07/14/2018, 12:09 AM
    Hey! I am using Appcode to make iOS project using Kotlin/Native. I want to use the htpp client for Native - https://github.com/e5l/http-client-common. So, I add the repo and dependency in Gradle as stated in the Readme and use it in the ViewController file by importing it. However, I get a compilation error about unresolved reference io for the statement import io.ktor.common.client.* Also, the sample project in that repo uses kotlin-platform-native plugin while I use konan and kotlin plugins. Which one is preferred and why? The sample appcode project uses konan and kotlin (granted its a bit dated as one has to change settings to use gradle 4.7 to even get it to compile but still).
    e
    • 2
    • 2
  • n

    Nikolai

    07/14/2018, 7:32 AM
    Hello, Everyone I am trying Kotlin-Native because I am very interesting in creating multiplatform apps for iOS and Android. As soon as Kotlin-Native become available I tried to setup multiplatform project with common code module. - I created a Kotlin (Multiplatform-Experiment) project with IDEA. It had two platform specific modules - jvm (for Android) and js (I just ignore it) and common module. - Created new project in Android Studio and imported common and jvm module from previous step - Implemented project for android side. All UI code is in Android Studio project, code that supposed to be common - in common module. For logic that supposed to be platform specific common module use expect class syntax and those classes implemented in jvm module. Now, I wanted to implement iOS part in AppCode. How I should import common module and implement platform specific logic? Or maybe I am doing it all wrong and multiplatform project should be implemented using different flow? I tried to look into Spinner App from Kotlin Conference, but it's so big for me where are many parts and I can't understand how to implement only two projects for client-side. Thanks for your help.
    a
    s
    • 3
    • 3
  • a

    Aregev2

    07/14/2018, 11:02 AM
    Will
    String.format
    be available in native?
    👍 3
    a
    m
    a
    • 4
    • 11
  • s

    spierce7

    07/15/2018, 6:29 PM
    Is there something I can do to make exceptions more readable from Kotlin/native? The exceptions I'm reading don't even have line numbers, and could easily become very difficult to diagnose.
    a
    • 2
    • 2
  • t

    thevery

    07/15/2018, 6:36 PM
    Ok it looks like main stopper for now (except json but that's easy with expect/actual or kotlinx.serialization) is threading - what is the state for coroutines for K/N, is there any sample available for iOS?
    n
    • 2
    • 1
  • s

    spierce7

    07/15/2018, 6:46 PM
    I'm struggling to use pointers properly with Kotlin/native in ObjC interop. I found a SO post with clear ObjC / Swift instructions to use an API, and I'm struggling to replicate in Kotlin: https://stackoverflow.com/a/48030215/471744
    val windowInfoList = CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID)!!
    windowInfoList
    is of type
    CFArrayRef
    , and no matter what I do I can't figure out how to use it / get at the items in the array. Any help would be appreciated. Here is the documentation for the function: https://developer.apple.com/documentation/coregraphics/1455137-cgwindowlistcopywindowinfo
    a
    • 2
    • 4
  • m

    mcastiblanco

    07/16/2018, 12:19 AM
    @ilya.matveev I found that the cause for
    Could not find org.jetbrains.kotlin:kotlin-native-shared:0.8.
    was that my project was using gradle
    4.7
    . It seems that K/N
    0.8
    requires
    4.8.1
    , at least for multiplatform projects
    i
    • 2
    • 3
  • s

    spierce7

    07/16/2018, 1:06 AM
    I'm having trouble including multiple Kotlin files in my kotlin/native gradle project. Everything works if I keep everything in a single file. As soon as I move some extension functions into another Kotlin file in the src dir, I can't access it anymore. How do I tell Gradle to compile multiple Kotlin/native files?
    m
    • 2
    • 3
  • n

    napperley

    07/16/2018, 2:55 AM
    Was hoping to see a Ktor HTTP Client library for Linux, aka ktor-client-linux 🙏 ( https://github.com/ktorio/ktor/tree/mpp-client/ktor-client ) but that is missing 🙁.
    g
    e
    • 3
    • 7
  • d

    Dmitry Kandalov

    07/16/2018, 8:27 AM
    Is there something like LinkedList in Kotlin Native? (I also wonder if there are good reasons not to implement it as part of multiplatform
    kotlin.collections
    🤔)
    e
    • 2
    • 4
Powered by Linen
Title
d

Dmitry Kandalov

07/16/2018, 8:27 AM
Is there something like LinkedList in Kotlin Native? (I also wonder if there are good reasons not to implement it as part of multiplatform
kotlin.collections
🤔)
e

elizarov

07/16/2018, 8:35 AM
What is your use-case for LinkedList?
d

Dmitry Kandalov

07/16/2018, 8:45 AM
Using it as a queue.
e

elizarov

07/16/2018, 8:47 AM
We plan to introduce multi-platform
ArrayDeque
(both K/N and JS) for this use-case. See https://youtrack.jetbrains.com/issue/KT-21327
(It is several times faster than linked list for a queue use-case)
👍 2
View count: 5