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

    Brian Donovan

    10/29/2021, 2:32 AM
    what does it mean when you are asked, What is a return type in Kotlin?
    a
    2 replies · 2 participants
  • m

    mbonnin

    10/29/2021, 5:33 PM
    Can I have the XCode "malloc guards" but when running a
    test.kexe
    binary?
    1 reply · 1 participant
  • a

    ankushg

    10/29/2021, 5:38 PM
    In 1.5.31, do release XCFrameworks include dSYM files? The docs on the Symbolicating iOS Crash Reports page say
    By default, Kotlin/Native compiler produces 
    .dSYM
     for release (i.e. optimized) binaries on Darwin platforms
    But the docs for building XCFrameworks only mention dSYMs for the debug task Digging in deeper, the source for
    XCFrameworkTask
    seems to only check for
    dSYM
    files for debug builds.
    👍 1
    👀 1
    t
    7 replies · 2 participants
  • t

    tunedal

    10/29/2021, 6:59 PM
    It it possible to run a Kotlin/Native binary on CentOS 6? Or more specifically CloudLinux, which is apparently based on CentOS 6. A normal executable fails because of the extremely ancient glibc, so I tried building a static library and bootstrapping it from a C program compiled on the target host with
    gcc -ldl -lm -lpthread -lstdc++ hello-kt.c libuntitled.a
    , but that fails due to various undefined symbols such as
    std::chrono::_V2::steady_clock::now()
    and
    __cpu_model
    .
    n
    1 reply · 2 participants
  • u

    吴少滨

    11/03/2021, 7:16 AM
    I see that KotlinRoadMap update the status of interoperability with C++ from ⏸️(Postponed) to ❌(Removed) lately.Is that show kotlin directly C++interop is impossiable forever?What are the difficulties of C++Interop?
    e
    1 reply · 2 participants
  • m

    mbonnin

    11/03/2021, 3:19 PM
    Adding all the darwin targets (
    macosArm64
    ,
    iosArm64
    ,
    watchosArm64
    ,
    watchosSimulatorArm64
    ,
    tvosArm64
    ,
    tvosX64
    ,
    tvosSimulatorArm64
    , ...) our CI build times took a 40min hit 😕 . Is there any chance the compiler could optimize "something" down there as from the distance it looks like it's doing the same thing over and over again?
    👀 1
    r
    a
    +4
    29 replies · 7 participants
  • m

    mbonnin

    11/03/2021, 3:25 PM
    Somewhat related to the above, what is the difference between
    iOSArm64
    and
    iOSSimulatorArm64
    ? Could they somehow be merged as the instruction sets are the same? Or are the APIs different somehow?
    👀 1
    s
    k
    +4
    36 replies · 7 participants
  • j

    Justin

    11/03/2021, 7:02 PM
    For those of you who haven't yet fully descended down the rabbit hole that is building a truly universal XCFramework for all iOS and macOS platform variants, I have published a gist with some custom gradle tasks that generate the desired result. Specifically, if you have a Kotlin Multiplatform library targeting all modern Macs (M1 Apple Silicon and Intel) and all iOS devices and simulators: •
    iosx64
    •
    iosArm64
    •
    iosSimulatorArm64
    •
    macosX64
    •
    macosArm64
    ...you can use these tasks to generate an XCFramework that works for all of them. XCFramework.kts The only 'official' Apple documentation on how to create such a framework (at least that I could find) is in an Apple forums post, so hopefully sharing this will (a) save other people time, and (b) lead to improvements on my amateurish gradle code!
    🎉 4
    👍🏼 1
    🔍 1
    s
    l
    3 replies · 3 participants
  • m

    Miroslav Sobotka

    11/03/2021, 9:33 PM
    Does somebody know what I'm doing wrong? https://youtrack.jetbrains.com/issue/KT-49558 The main Problem for me is the:
    LDAP *ld
    and then
    ldap_initialize(&ld, ...
    ldap_set_option(ld, ...
    How to properly implement this? Thanks!
    r
    1 reply · 2 participants
  • l

    Laurent Laborde

    11/04/2021, 3:43 PM
    Hi, I'm learning kotlin. Is it possible to use Apple's Metal with kotlin native ? I see openGL and Metal as an exemple of "nativity" for kotlin but I can't find any more than that
    b
    p
    +1
    6 replies · 4 participants
  • l

    Lukellmann

    11/05/2021, 6:29 PM
    Is there already some sort of documentation/specification for K/N's new experimental memory model? I'm thinking of something similar to https://docs.oracle.com/javase/specs/jls/se17/html/jls-17.html
    In particular I'm looking for some kind of volatile/acquire/release semantics
    k
    1 reply · 2 participants
  • j

    jimn

    11/07/2021, 8:39 PM
    struct arrays are apparently a bit of a grey area in K/N:
    #!c
    typedef struct request {
        int event_type;
        int iovec_count;
        int client_socket;
        struct iovec iov[];// <--- this 
    };
    in 1.5.31 this has no members, presumably silently errors during generation. in 1.6.0-RC it gains four members
    #!kotlin
    
    @kotlinx.cinterop.internal.CStruct public final class request public constructor(rawPtr: kotlinx.cinterop.NativePtr /* = kotlin.native.internal.NativePtr */) : kotlinx.cinterop.CStructVar {
        @kotlinx.cinterop.internal.CStruct.VarType @kotlin.Deprecated public companion object : kotlinx.cinterop.CStructVar.Type {
        }
        public final var client_socket: <http://kotlin.Int|kotlin.Int> /* compiled code */
        public final var event_type: <http://kotlin.Int|kotlin.Int> /* compiled code */
        public final val iov: kotlinx.cinterop.CArrayPointer<platform.posix.iovec> /* = kotlinx.cinterop.CPointer<platform.posix.iovec> */ /* compiled code */
        public final var iovec_count: <http://kotlin.Int|kotlin.Int> /* compiled code */
    }
    I have been naively porting this source c code using nativeHeap.alloc() and finally come to the part where the code does malloc(request.size+iov.size*6) the pointer needs to be long lived as this gets passed to the linux kernel and is immediately freed when the kernel returns it. that said, the goal is using uring with stable kotlin pointers when im done porting the webserver sample, not to preserve c code. should i stick with a factory method that takes the array size and uses malloc or is there a similar OO snippet somewhere that can get the job done with an aligned flat byte-expanse?
    e
    1 reply · 2 participants
  • k

    KV

    11/08/2021, 8:14 AM
    Hey, Have a question: I am using MVVM pattern in the app & my approach is: After button click from From Fragment A, navigate to Fragment B, call viewmodel, call APIs from the server (usecase, repo & repo impl part), and the result would we shown to UI (Fragment B) after observing the data. So is there any way that, after button click from Fragment A, call the API and based on the response of the API, show updated UI in the Fragments B. Current Behaviour -> Fragment A -> click button-> navigate to Fragment B and do api calls via MVVM Expected Behaviour -> Fragment A -> click button -> API call -> show Updated UI in Fragment B Does anyone know how to achieve this kind of behaviour in our android application? TIA
    c
    9 replies · 2 participants
  • n

    natario1

    11/08/2021, 10:28 AM
    What's the difference between Pinned and StableRef? They look so similar besides maybe one being a data class and another a value class. Wouldn't one of them be enough?
    d
    j
    9 replies · 3 participants
  • w

    William Reed

    11/10/2021, 6:39 PM
    For anyone on an m1 mac, how has your experience with kotlin native been? any snags or has that all been worked out?
    h
    t
    +2
    12 replies · 5 participants
  • j

    jimn

    11/12/2021, 5:08 PM
    I'm linking a c lib which succeeds at finding the headers and satisfying the def linker requirements
    -luring
    and shows up as complete in the kotlin/idea compiled cinterop code. the exe compiles and runs but when it hits the liburing struct definition there should be a static const int size, but instead the exe bails with a cryptic error code. there are a number of glibc/kernel headers which are getting the job done until it gets to this missing constant.
    n
    4 replies · 2 participants
  • j

    Justin

    11/13/2021, 7:23 PM
    https://kotlinlang.slack.com/archives/C0A974TJ9/p1636831427305600
    e
    e
    5 replies · 3 participants
  • m

    Michael Clancy

    11/14/2021, 2:00 PM
    Hi there, anyone know how I might provide a custom cinterop def file when using a cocoapod? For some context, I am wanting to use a framework in a cocoapod which contains C++ and C header files, but am wanting to specify header filters to ignore the C++ headers, otherwise cinterop fails. Downloading the framework and referencing it locally works using the header filter, but curious as to whether I can specify this when using a cocoapod. Thanks, Michael
    k
    2 replies · 2 participants
  • n

    napperley

    11/17/2021, 12:21 AM
    Trying to translate
    NewSettings.c_lflag &= ~( ICANON | ECHO );
    (C language) to Kotlin, and have hit a brick wall 🧱 with the bit manipulation since there appears to be some bit manipulation operations that can't be done in Kotlin, unless there are some workarounds available. Below is the full C code I am trying to translate into Kotlin:
    #include <termios.h>
    static struct termios OriginalSettings, NewSettings;
    void terminal_setup()
    {
        tcgetattr(STDIN_FILENO, &OriginalSettings);
        NewSettings = OriginalSettings;
        NewSettings.c_lflag &= ~( ICANON | ECHO );
        tcsetattr(STDIN_FILENO, TCSANOW, &NewSettings);
        printf("\e[?25l");
    }
    void terminal_reset()
    {
        tcsetattr (STDIN_FILENO, TCSAFLUSH, &OriginalSettings);
    }
    m
    2 replies · 2 participants
  • n

    napperley

    11/17/2021, 12:36 AM
    Does Kotlin Native have a feature for copying values from one struct to another that is of the same type? Currently doing the following which is tedious/error prone:
    // ...
    private val globalArena = Arena()
    private val originalSettings = globalArena.alloc<termios>()
    private val newSettings = globalArena.alloc<termios>()
    // ...
    private fun setupTerminal() {
        tcgetattr(STDIN_FILENO, originalSettings.ptr)
        newSettings.run {
            c_ispeed = originalSettings.c_ispeed
            c_ospeed = originalSettings.c_ospeed
            c_line = originalSettings.c_line
            c_oflag = originalSettings.c_oflag
            c_cflag = originalSettings.c_cflag
            c_iflag = originalSettings.c_iflag
            // ...
        }
        // ...
    }
    m
    1 reply · 2 participants
  • m

    Marcin Wisniowski

    11/17/2021, 10:12 PM
    I am trying to link to a C library in my program I am cross-compiling, I have compiled a
    .so
    library on my target, and copied it back to my development box. I can use library functions and the project compiles, but it fails at linking with:
    .[..]/.konan/dependencies/arm-unknown-linux-gnueabihf-gcc-8.3.0-glibc-2.19-kernel-4.9-2/arm-unknown-linux-gnueabihf/bin/ld.bfd: src/nativeInterop/cinterop/libpigpio.so: undefined reference to glob@GLIBC_2.27'
    It looks like Kotlin/Native is trying to compile with a different version of glibc than I compiled the library with, and it doesn't work. But how do I choose the glibc version in my project?
    👀 1
    ✅ 1
    1 reply · 1 participant
  • p

    Piotr Krzemiński

    11/18/2021, 2:06 PM
    I have this develoment board: STM32F429I-DISCO, and I want to try Kotlin on it. My first idea is to skip the JVM stuff (in theory possible since you can have linux there) and try Kotlin/Native. I see here that @BradW you tried it - any luck? This ticket from 3 years ago and this thread don't give much hope, however these release notes mentioning "Experimental support for Zephyr RTOS" do give hope 🙂 Anyone could share their experience?
    👀 1
    n
    j
    18 replies · 3 participants
  • b

    Brian G

    11/18/2021, 5:10 PM
    I'm hitting the weirdest bug in production randomly (automated reporting) and I don't know how to reproduce... This code:
    fun apiUrl(param: String): String {
        return "/v2/$param"
    }
    Is somehow returning
    "/v2/kotlin.Unit"
    and hitting my server. Anyone seen anything like this? My code is multiplatform (Android/iOS/JS), but these are only coming from the iOS Kotlin/native version.
    😬 1
    c
    4 replies · 2 participants
  • c

    Clocks

    11/18/2021, 5:13 PM
    Kotlin/Native application using
    gtk-kt
    to play video. (There is audio, but pipewire is being a tad buggy so it is not included) I made this in under an hour, with a bit of debugging. It's impressively easy to make a GTK video player with Kotlin/Native :D
    2021-11-18 12-08-17.mkv
    :kotlin-intensifies: 9
    🎉 11
    e
    4 replies · 2 participants
  • o

    oshai

    11/18/2021, 11:04 PM
    Does anyone has an example of building osx builds with travis?
    b
    6 replies · 2 participants
  • n

    napperley

    11/19/2021, 12:38 AM
    @Artyom Degtyarev [JB] - Why is there no official Kotlin Linux/Embedded Linux development survey?
    a
    1 reply · 2 participants
  • p

    Paul Woitaschek

    11/19/2021, 7:33 AM
    I've just published a blog post on generating swift code for kotlin native using KSP and swiftpoet: https://medium.com/@woitaschek/kotlin-native-using-swift-not-objective-c-d7742c040539 I'd love to hear your feedback on this 🙂
    👀 2
    🤩 3
    👍 1
    h
    a
    9 replies · 3 participants
  • l

    Luigi Scarminio

    11/19/2021, 5:30 PM
    I implemented an XML parser on KMM and I'm calling it from iOS at the press of a button. But when the function ends its scope, I'm not seeing a reduction in memory usage. What am I missing?
    class ViewController: UIViewController {
    
        @IBAction func importDatabase(_ sender: UIButton) {
            let xmlImporter = AirportXMLImporter(airportDatabaseService: DatabaseService())
    
            (1...5).forEach{ index in
                xmlImporter.parseXmlFile(path: Bundle.main.path(forResource: "airports-mundial", ofType: "xml")!)
                    .subscribe(isThreadLocal: false,
                               onError: {error in},
                               onSuccess: {result in }).dispose()
    
            }
        }
    
        override func viewDidLoad() {
            super.viewDidLoad()
        }
    
    }
    The XML parser is the AirportXMLImporter. DatabaseService is injected as a persistence layer. DatabaseService is implemented in Swift.
    1 reply · 1 participant
  • c

    Clocks

    11/19/2021, 8:28 PM
    Goodbye GitHub, Hello GitLab https://gitlab.com/gtk-kt/gtk-kt (Also who loves logos, I made this one with kotlin colors :D)
    💯 1
    :kotlinnew: 1
    b
    j
    14 replies · 3 participants
  • n

    napperley

    11/20/2021, 3:09 AM
    Trying to do some basic Linux Frame Buffer stuff by following this tutorial: https://kevinboone.me/linuxfbc.html None of the symbols in linux/fb.h can be imported even though the Linux Frame Buffer (User Space) library is part of the Linux Kernel. Will this issue be addressed in the Kotlin 1.6.10 release?
    n
    3 replies · 2 participants
Powered by Linen
Title
n

napperley

11/20/2021, 3:09 AM
Trying to do some basic Linux Frame Buffer stuff by following this tutorial: https://kevinboone.me/linuxfbc.html None of the symbols in linux/fb.h can be imported even though the Linux Frame Buffer (User Space) library is part of the Linux Kernel. Will this issue be addressed in the Kotlin 1.6.10 release?
There needs to be a standard process to quickly add support for standard Linux Kernel user space libraries. Every time a Kotliner reports a similar issue it should be treated as a severe bug (a stability/polish issue) that needs to be fixed quickly (in the next minor Kotlin release).
n

natario1

11/20/2021, 1:31 PM
I think it's easier for you to open an issue and follow up with a PR to the platform libs, presumably here https://github.com/JetBrains/kotlin/blob/master/kotlin-native/platformLibs/src/platform/linux/linux.def . From merging until release, from my experience, you can expect a few months delay. But you can use cinterop in your own project during this time
n

napperley

11/21/2021, 12:53 AM
Found a simple workaround that works (tested with the linuxArm32Hfp target on a Rpi 4). Create and use a def file that contains the following:
package = frameBuffer
---
#include <linux/fb.h>
View count: 9