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

    Clocks

    03/08/2021, 4:16 AM
    I learned a ton, And it was extremely fun to develop it. Now my goals are: 1. To completely wrap gtk in kotlin 2. Seperate the gtk wrap and the dsl into two separate libraries
    👍 4
    a
    • 2
    • 2
  • k

    KamilH

    03/10/2021, 8:44 AM
    I’m trying to better understand a memory management in Kotlin Native. I thought that accessing some property of the class from the same thread is safe, however I’m getting
    InvalidMutabilityException
    when launching new coroutine on Main Dispatcher (code in thread).
    m
    t
    u
    • 4
    • 48
  • k

    KamilH

    03/12/2021, 4:42 PM
    What I’m really missing, while working with K/N’s memory management, is some kind of tutorial or list of good practices or patterns how to solve common problems. Especially with
    coroutines
    library, because I think it’s a way most of us doing background job in KN. There are a lot of articles that are trying to explain concurrency topic and this is great. However at the end of the day when you are starting to work with it, you implement simple class that keeps state, state is getting accessed in background thread and you are getting
    InvalidMutabilityException
    . When I get this the only easy way to work around this was to use “AtomicReference”, but later I started thinking if it’s the best solution and it is really not obvious to answers. Some questions, that it would be great to know answers to: • How to implement simple in memory cache? With and without
    Map
    (with one value that is nullable and with
    Map<V,K>
    )? • How to implement a class that does something, keeps internal state, but we don’t know on what thread it is going to be used? • For collections that keeps state, should we use
    IsoMutableList
    or
    MutableList<AtomicReference>
    ? Will they work similarly? What are the performance implications? • Is
    StateFlow
    useful when it’s about keeping a state?
    👍 2
    m
    r
    +2
    • 5
    • 8
  • j

    joshshin

    03/12/2021, 11:50 PM
    Does anyone know what happens when you call
    freeze
    on a
    CompletableDeferred
    ? I was playing around with multithreading, created a
    CompletableDeferred<SOME_DATA_CLASS>
    on the main thread, froze it, passed it to a background thread , then passed it back to the main thread and called
    complete(SOME_VALUE)
    on it. This seemed to actually work, but it doesn't seem like it should.
    r
    • 2
    • 3
  • c

    caffeine

    03/14/2021, 11:15 AM
    Hello! Can I malloc some memory that will free with my object where I was malloc memory? or If I wrote something like
    class Buffer(val capacity:Int){private val mem = ByteArray(capacity); val ptr = mem.refTo(0);}
    variable
    ptr
    will be stable? Can I use value of
    ptr
    during all object life cycle?
    d
    • 2
    • 3
  • c

    Clocks

    03/14/2021, 10:30 PM
    Kotlin/Native, has a bumpy start for development. The learning curve is a tad confusing at times. But overall I have to say I enjoy it. Now that I have gotten past the initial bump, Writing kotlin-gtk has become extremely smooth. It's mostly just the annoying slow wrapping of native -> pure kotlin
    p
    • 2
    • 15
  • s

    Shannon Duncan

    03/15/2021, 2:32 PM
    Ok so been googling and can’t find a good answer. I’ve got a library written in Kotlin multiplatform. The ios fat-framework (arm32&arm64) is a whole 11.5MB. Is there any way I can remove unused parts of the stdlib or something to bring that down. It is basically one class file.
    s
    n
    • 3
    • 12
  • a

    Artyom Degtyarev [JB]

    03/15/2021, 3:28 PM
    Hello everyone! I’m Artyom, Support Engineer for the Kotlin/Native team. We’ve been talking about using Kotlin for native targets with you for some time, and now I would like your help. I’m performing a small research project on the Kotlin/Native’s Linux x86-64 target state. At this stage, I want to collect some data about its use and how common it is compared to other targets.  If you’re targeting desktop Linux with Kotlin/Native and would like to participate in an interview (video or audio) about ~30 minutes long, please contact me. Write me a DM, or use the 🙋 reaction below.
    🙋 5
    s
    b
    +5
    • 8
    • 15
  • c

    Clocks

    03/17/2021, 2:48 AM
    Full GTK3 Wrap K/N is going well. Took 54 ms to build this entire UI. Not sure if that is good or not, or how it compares to other applications
    👍🏼 1
    :kotlin-intensifies: 6
    👍 4
    👏 2
    s
    n
    • 3
    • 10
  • k

    kpgalligan

    03/17/2021, 5:17 PM
    Is
    org.jetbrains.kotlin:backend.native
    published anywhere publicly accessible?
    • 1
    • 1
  • c

    charleskorn

    03/18/2021, 4:09 AM
    Sorry if this is already answered somewhere else, but I can’t find a recent answer to this: are there any plans for a mocking library that supports Kotlin/Native? This seems like a big missing part of supporting unit testing in Kotlin/Native
    e
    • 2
    • 1
  • c

    Carmi Grushko

    03/19/2021, 8:09 PM
    Does kotlin-compiler itself can be built under Kotlin/Native? I’m working on https://github.com/facebookincubator/ktfmt, which currently requires Java 11. I’d like to compile to a native image so (1) it’s easier to use by organizations that haven’t moved to Java 11 and (2) an AWS Lambda that runs ktfmt has faster cold startups. Ktfmt depends on Kotlin-compiler and parts of google-Java-format. The latter should be easy to build under Native, the former I’m not so sure.
    j
    t
    +2
    • 5
    • 8
  • m

    Michal Klimczak

    03/20/2021, 10:11 PM
    I'm trying to override an ios protocol with some `optional func`tions but for one method I cannot get it: https://developer.apple.com/documentation/foundation/xmlparserdelegate
    func parser(XMLParser, didStartElement: String, namespaceURI: String?, qualifiedName: String?, attributes: [String : String])
    
    //in kotlin native
    override fun parser(
        parser: NSXMLParser,
        didStartElement: String,
        namespaceURI: String?,
        qualifiedName: String?,
        attributes: Map<String, String>
    )
    An example of one that works fine for comparison:
    func parser(XMLParser, parseErrorOccurred: Error)
    
    override fun parser(parser: NSXMLParser, parseErrorOccurred: NSError)
    • 1
    • 1
  • c

    Clocks

    03/21/2021, 1:16 AM
    What is a char converted to in kotlin/native?
    e
    • 2
    • 4
  • c

    Clocks

    03/21/2021, 4:04 AM
    https://github.com/Doomsdayrs/kotlinx-gtk/.../TreeModel.kt#136 if anyone needs to know how to convert a staticCFunction callback to a flow, this example can clear it up for you. Sorry for the lack of documentation, I'm mostly speed running wrapping.
    :thread-please: 3
    m
    • 2
    • 1
  • p

    phisch

    03/21/2021, 11:16 AM
    Are you still wrapping by hand instead of generating?
    c
    • 2
    • 1
  • c

    Clocks

    03/23/2021, 6:35 AM
    Tons done with kotlinx-gtk • Sped up build time by separating DSL from wrapper • Added dsl functions to create UI elements outside of the main dsl I am getting in contact with GTK devs to create the testing application they showcase in dev blogs
    :kotlin-intensifies: 7
    🎉 8
    m
    d
    • 3
    • 3
  • р

    Ролан

    03/23/2021, 11:01 AM
    I am a bit confused by the
    memScoped
    behaviour :
    val qOut = memScoped {
                val q = allocArray<IntVar>(6)
                q[0] = 56
                q
            }
    println(qOut[0]) //prints 56
    shouldn't have the memory behind
    q
    been released?
    a
    • 2
    • 2
  • n

    napperley

    03/24/2021, 9:45 PM
    In a Kotlin Native project containing a linuxX64 module the build works fine. After adding the linuxArm32Hfp module the build breaks with the following error:
    Cannot resolve external dependency org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.4.31 because no repositories are defined.
    If the linuxArm32Hfp module is removed then the build works fine again like before.
    a
    • 2
    • 3
  • c

    Clocks

    03/25/2021, 3:40 AM
    Should I create every single DSL function, or should I spend time wrapping and let others help me create DSL later? Milestone, nearing 10,000 total lines
    g
    • 2
    • 2
  • e

    Eric O'Connell

    03/26/2021, 9:45 PM
    Is there any informal guidance as to when we might expect the new memory model to land? re: https://blog.jetbrains.com/kotlin/2020/07/kotlin-native-memory-management-roadmap/
    ➕ 1
    👀 8
    r
    d
    • 3
    • 2
  • n

    napperley

    03/28/2021, 7:11 PM
    There is an official GitLab template available for creating a new Kotlin Native project that is used for developing a Linux program: https://gitlab.com/gitlab-org/project-templates/kotlin-native-linux
    👍🏼 1
    🎉 5
    👍 2
    :party-parrot: 2
    s
    • 2
    • 2
  • n

    nimrod

    03/28/2021, 9:46 PM
    Hi, I’m working on a KMM module for network service discovery. On iOS side, when I implement a delegate, such as
    NSNetServiceDelegateProtocol
    , I don’t see any of the actual methods of that delegate, but only of the parent interface
    NSObjectProtocol
    . Is this possible at all? Please see attached screenshot of the issue in Android Studio. Thanks!
    l
    • 2
    • 2
  • a

    andylamax

    03/29/2021, 7:12 AM
    Anyone using github actions. Can someone please guide me on how I can cache konan (kotlin native compiler) to quicken my CI process? CI keeps downloading the artifacts everytime it runs.
    a
    • 2
    • 14
  • t

    Toby

    03/30/2021, 6:57 PM
    So Kotlin/Native is slower than Kotlin/JVM? I thought it gets compiled by LLVM to achieve native code
    c
    e
    • 3
    • 6
  • b

    Big Chungus

    03/31/2021, 2:54 PM
    Is there any way to add cinterops to custom nativeMain sourceSet that all my native targets depend on?
    📨 2
    k
    m
    +3
    • 6
    • 44
  • b

    Big Chungus

    03/31/2021, 4:21 PM
    How do you test suspending functions in Kotlin Native?
    k
    r
    • 3
    • 3
  • b

    Big Chungus

    03/31/2021, 7:24 PM
    How do you add additional directiries to linker context so that libraries in
    linkerOpts
    would get found? Also, is there a konan
    .def
    file schema somewhere?
    k
    m
    • 3
    • 3
  • s

    Susheel

    03/31/2021, 8:26 PM
    I have this data class
    @Serializable
    data class User(
        @SerialName("UserName")
        val name: String,
        @SerialName("UserId")
        val userID: String,
    )
    and yet I'm seeing the following exception
    name: Error Domain=KotlinException Code=0 "No transformation found: class kotlin.ByteArray -> class com.xxx.kmmsharedmodule.User
    in my kmm module
    r
    l
    • 3
    • 9
  • m

    Michal Klimczak

    04/03/2021, 5:49 PM
    How do I write kotlin
    ByteArray
    to ios
    NSOutputtream
    ?
    fun writeBytes(bytes: ByteArray, outputStream: NSOutputStream){
            outputStream.write(WHAT NOW)
        }
    Or something similar that lets me write a byte stream to a file on ios.
    • 1
    • 1
Powered by Linen
Title
m

Michal Klimczak

04/03/2021, 5:49 PM
How do I write kotlin
ByteArray
to ios
NSOutputtream
?
fun writeBytes(bytes: ByteArray, outputStream: NSOutputStream){
        outputStream.write(WHAT NOW)
    }
Or something similar that lets me write a byte stream to a file on ios.
I found something like this, but it seems to be extremely slow, the file loads many, many times slower than on jvm. https://github.com/cquemin/Krypto/blob/5e32d211e42d4a4ce47a2802f3125d5cad9b2b4f/co[…]m/island/yoshiz/mpp/krypto/common/model/streams/OutputStream.kt Will probably just try okio 3.0...
View count: 14