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

    Ryan Loebs

    09/12/2021, 9:31 PM
    Is there a way to pass a kotlin vararg to a variadic C function? I'm trying to pass through a printf-style log callback to
    snprintf
    to do the actual formatting but I've been unable to find a way to do it. At this point I'm thinking of trying a convoluted approach of writing a C method that I can pass as the initial callback that will do the snprintf in C code, then callback into my kotlin code with the final string.
    e
    c
    • 3
    • 8
  • y

    Yaniv Sosnovsky

    09/14/2021, 11:06 AM
    Hi. I have a project with multiple modules in my project. I have a ‘core’ module, and ‘feature’ modules. The core module initializes a Singleton ‘object’ that is later being consumed by the ‘feature’ module(works as expected for Android) .However,I have noticed that the singleton object is being instantiated twice in iOS. when I looked deeper into this, I noticed that because both of the pods (core, and feature) were added to the iOS app, the ‘core’ module is being added twice(?) - once by the pod itself, and once again by the ‘feature’ module that is dependent on the ‘core’ module in KMM. Is there a way of dealing with this? How can I share information between modules if this is indeed a limitation? I can try to share data by writing to a db of some sort, but is this really the only option?
    s
    • 2
    • 4
  • b

    Brian Donovan

    09/15/2021, 5:34 PM
    why can’t we add a constructor to a object class{}?
    e
    • 2
    • 5
  • a

    Arkadii Ivanov

    09/17/2021, 8:46 PM
    I noticed that all entries in
    timespec
    are of type
    <http://kotlin.Int|kotlin.Int>
    for
    watchosArm64
    target,
    __darwin_time_t
    is also defined as
    <http://kotlin.Int|kotlin.Int>
    . Is it by design? Shouldn't it be
    kotlin.Long
    ?
    r
    • 2
    • 1
  • j

    Joffrey

    09/18/2021, 10:09 PM
    Hey guys, I'm trying to run the example iOS websocket code from Kotlin docs' example in my
    iosTest
    (unit tests), but everything is just stuck. I saw this comment in a very old thread, and I'm thinking maybe it's the same "queue is not run" problem. Is there anyway for me to run this queue within an iOS unit test? I'm writing a multiplatform library so I don't have an iOS app project. It looks like I don't have access to
    NSApplication
    there.
    t
    • 2
    • 9
  • n

    napperley

    09/19/2021, 2:03 AM
    Would be nice if there was a way to solve the problem of doing Kotlin Native development in an isolated environment without affecting the host's system environment 😄. Recently I have run into that problem when trying to use the EFL library ( https://en.wikipedia.org/wiki/Enlightenment_Foundation_Libraries ) in a Kotlin Native project ( https://gitlab.com/napperley/efl-hello ). I want to use the latest stable version of EFL (the libefl-all-dev Debian Package is missing key header/library files that should be present), however that is very likely to screw up the host system environment 😦. Building EFL from source for a Linux host requires satisfying a gazillion different dependencies 😱. Sadly a Kotlin Native developer, "cannot make their cake and eat it", this is why we can't have nice things 😦. From the suggestions made from some Kotlin team members in the past ( https://youtrack.jetbrains.com/issue/KT-43501 ) on linking C libraries I don't think any of them use a Linux PC on a regular basis for Software Development; "It takes one to walk in ones shoes" in order to understand the issues they face, and how they do things.
    s
    • 2
    • 18
  • h

    hfhbd

    09/19/2021, 12:01 PM
    How do you get more details from failing K2Native compiler, eg by providing arguments to the compiler (with gradle)? I am getting this error message and would like to find the root cause/file:
    e: Compilation failed: Symbol for public platform.Foundation/NSCopyingProtocol|null[100] is unbound
    
     * Source files: 
     * Compiler version info: Konan: 1.5.30 / Kotlin: 1.5.30
     * Output kind: FRAMEWORK
    r
    • 2
    • 3
  • n

    napperley

    09/20/2021, 12:16 AM
    Have the Kotlin team looked at setting up a Linux Device Lab for testing Kotlin Native on a wide range of different Linux/Embedded Linux based devices?
    j
    b
    • 3
    • 17
  • a

    ankushg

    09/20/2021, 7:39 PM
    Hey friends! Is anyone using the Cocoapods Gradle plugin for debugging/iteration, but then a versioned/hosted private pod for "normal" iOS development? If so, how do you toggle between the two? Any tricky bits to watch out for? Context: We're currently only publishing our KMP XCFramework as a private pod, which we've automated through Gradle, but is still slow for iterative work. Our iOS devs are interested in being able to debug faster with the cocoapods gradle plugin when they're iterating in KMP code, but they're also hesitant to link the iOS and KMP projects for everyday work because their build times are already slow enough as it is.
    r
    n
    • 3
    • 10
  • j

    James

    09/21/2021, 2:56 PM
    Hey everybody, is there a way to pass a nullable primitive pointer to a Kotlin function? Context: I'm trying to pass a Kotlin function to a C library as a callback and it needs to accept a nullable primitive pointer as an argument. More info in thread.
    n
    • 2
    • 6
  • k

    kpgalligan

    09/21/2021, 3:42 PM
    Running into a cinterop issue.
    typedef struct
    produces a kotlin definition with package
    cnames.structs
    . I don't think it's possible to change the package used, or I can't find a way in the docs. It works OK on linux, but we have a name collision with a darwin platform struct. It doesn't make a lot of sense to me. They have the same name, but when I navigate to the type in the IDE, the darwin platform type has a different package. In our code, we import `import cnames.structs.JSContext`and that works for target
    linuxX64
    but not for
    iosX64
    (
    macosX64
    , etc). Any quick thoughts before I start deep diving? Thanks in advance...
    n
    j
    • 3
    • 4
  • k

    kevin.cianfarini

    09/22/2021, 6:30 PM
    I’m trying to bridge a C++ library to Kotlin/Native by creating a C intermediary. The c++ project is compiled using gradle’s 
    cpp-library
    . Unfortunately it seems that this grade plugin doesn’t support mixed C/C++ sourcesets for compilation. So, does Kotlin cintertop work when a header file doesn’t use any C++ features, but the implementation is in C++? Is it even possible to implement a C header files with C++? I’m a total C++ noob. Any help is appreciated 🙂
    🇳🇴 2
    n
    • 2
    • 1
  • n

    napperley

    09/22/2021, 10:17 PM
    Found something that was a very alarming, and hopefully a member of the Kotlin Team can provide a good explanation why the RAM usage is high. I have two different versions of a Kotlin Native program, one targeting linuxX64, and the other targeting linuxArm32Hfp. The linuxX64 version uses significantly less RAM (at 6.9 MB) than the linuxArm32Hfp version (at 23 MB) 😱. The linuxArm32Hfp version uses over three times the amount of RAM that the linuxX64 version uses which is cause for huge concern. Originally when I saw something similar occurring (with a different Kotlin Native program) I thought I must have made some major mistakes when developing the Kotlin Native program, however the pattern that is emerging suggests otherwise.
    👀 3
    a
    • 2
    • 4
  • f

    fabianterhorst

    09/24/2021, 9:03 AM
    Hi, i have a small problem when using objectivec interop def files. When i include
    #import <Foundation/NSBundle.h>
    im getting the following error
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:143: error: function does not return NSString
    i couldn't find anything that would explain this error. The error is also happening when i include
    #import <Foundation/Foundation.h>
    or
    #import <UIKit/UIView.h>
    since that all includes all foundation headers internally.
    s
    • 2
    • 3
  • j

    Jan

    09/24/2021, 5:24 PM
    Hi! I have this error when trying to compile my program. My program uses a bigger self-made multiplatform project which uses Ktor and Korio. Mabye there is a problem. Error:
    C:\Users\jan\.konan\dependencies\msys2-mingw-w64-x86_64-clang-llvm-lld-compiler_rt-8.0.1\bin\ld: cannot find -lcurl
    c
    • 2
    • 2
  • n

    napperley

    09/27/2021, 9:10 PM
    The cinterop tool isn't generating the proper mappings for the String Share APIs ( https://www.enlightenment.org/develop/guides/c/eina/strings.md ) that are part of the EFL library. For example the
    eina_stringshare_replace
    function should accept a CPointer<Eina_StringshareVar>? as the first parameter. Instead the function only accepts a CValuesRef<CPointerVar<Eina_StringshareVar>>? as the first parameter.
    e
    • 2
    • 4
  • k

    kevin.cianfarini

    09/28/2021, 6:06 PM
    How do I free a piece of memory which has it’s own custom free function written in C and its lifetime is tied to the lifetime of a K/N object? I don’t think
    memScope
    would work for this, but I’m unsure
    n
    u
    • 3
    • 7
  • a

    ansman

    09/29/2021, 12:37 AM
    Can someone point me in the right direction in debugging issues like this while compiling:
    e: Compilation failed: Symbol for public com.example/Example.stuff.<get-stuff>|-6269057140886526916[0] is unbound
    n
    • 2
    • 2
  • l

    leandro

    09/29/2021, 12:35 PM
    Has anyone shared a module that uses kotlinx.serialization to iOS? Even if I use implementation() in my build.gradle, it still exposes Decoder on my header file, like so:
    __attribute__((swift_name("Decoder")))
    @protocol CommonDecoder
     (BOOL)decodeBoolean __attribute__((swift_name("decodeBoolean()")));
    - (int8_t)decodeByte __attribute__((swift_name("decodeByte()")));
    - (unichar)decodeChar __attribute__((swift_name("decodeChar()")));
    - (double)decodeDouble __attribute__((swift_name("decodeDouble()")));
    ...
    @end;
    this causes import issues with Swift.Decoder and Swift.Encoder. How can I change the swift_name of this class that I dont own?
    s
    • 2
    • 2
  • l

    leandro

    09/29/2021, 5:47 PM
    Has anyone had a crash on iOS of type terminateWithIllegalSharingException? I’m trying to insert a simple object from main thread to sqldelight using native-mt.
    k
    • 2
    • 6
  • g

    Gavin Ray

    09/29/2021, 6:44 PM
    Is there anything theoretically preventing someone from writing KN <-> Objective-C bindings to Skia and using them to render UI's on iOS? It seems like someone could do this and finish off the "Kotlin UI everywhere" story -- write once using a single UI toolkit and render on Desktop/Web/Mobile.
    t
    • 2
    • 1
  • j

    jw

    09/30/2021, 12:47 PM
    What is the reason that
    typedef struct Foo Foo;
    winds up as
    cnames.structs.Foo
    whereas
    typedef struct Foo { ... } Foo;
    goes into
    my.package.Foo
    ? I'm running into simple name collisions in
    cnames.structs
    which are causing compilation failures only on some native targets.
    s
    m
    • 3
    • 7
  • k

    kpgalligan

    10/01/2021, 1:03 PM
    Trying 1.6.0-M1. It looks like windows is being built on mac now? At least I see the mingwX64 folder. I may have missed that.
    s
    r
    +3
    • 6
    • 16
  • m

    martmists

    10/03/2021, 10:06 AM
    How do I use a git repository (kotlin-native) as a dependency?
    e
    • 2
    • 1
  • m

    martmists

    10/03/2021, 10:06 AM
    And how would I go about using a library like Skia, which is awful to set up in gradle?
    e
    • 2
    • 3
  • m

    martmists

    10/03/2021, 10:15 AM
    For the latter I looked at skiko, but the only native bindings available seem to be for macOS and not common native code.
    g
    • 2
    • 4
  • n

    natario1

    10/04/2021, 8:06 PM
    I wonder if anyone has any clue as to why androidNative executables don't work. I have a hello world executable that segfaults. Android logcat shows
    2021-10-04 21:47:44.065 0-0/? I/playground2.so[20392]: segfault at 0 ip 00000000f52ce047 sp 00000000ffe03130 error 6 in playground2.so[f52ce000+143000]
    2021-10-04 21:47:44.068 0-0/? I/Code: 00 00 00 d8 3e 2d 00 00 00 00 00 34 00 20 00 08 00 28 00 28 00 27 00 06 00 00 00 34 00 00 00 34 00 00 00 34 00 00 00 00 01 00 <00> 00 01 00 00 04 00 00 00 04 00 00 00 01 00 00 00 00 00 00 00 00
    I'm not experienced in native development, but none of my attempts led anywhere - addr2line gives ??, malloc debugging (here) does nothing. I managed to get a linux core dump and fed it to lldb, but I'm not able to get any information from it. The same code works perfectly when compiled as a shared library. Any clue on how to dig deeper before filing an issue?
    • 1
    • 1
  • s

    spierce7

    10/05/2021, 2:19 PM
    I’m getting an error when Kotlin cocoa pods is using cinterop.
    An operation is not implemented: support enum forward declarations: enum AEPLogLevel
    . What can we do?
    s
    • 2
    • 2
  • m

    mbonnin

    10/06/2021, 12:31 PM
    When my tests fail in a background thread, it doesn't show the exception message, just
    Test running process exited unexpectedly.
    and the stacktrace. Is it possible to install an uncaught exception handler in a native thread?
    b
    • 2
    • 3
  • l

    Landerl Young

    10/06/2021, 6:28 PM
    Need help when using compiler plugin on kotlin/native.
    😘 1
    n
    • 2
    • 2
Powered by Linen
Title
l

Landerl Young

10/06/2021, 6:28 PM
Need help when using compiler plugin on kotlin/native.
😘 1
n

napperley

10/07/2021, 1:17 AM
Compose isn't designed to work on Kotlin Native. The memory model that Compose works with is supported on Kotlin JVM/Kotlin Android/Kotlin JS, but not Kotlin Native.
l

Landerl Young

10/07/2021, 4:51 AM
Thanks for the reply, but these should not be related, compose is just a framework that can work even on a single-threaded application (that’s exactly compose-web does). For now I’m trying to make compose work on a single threaded kotlin/native application. (Also, there is a new memory model for KN be working on).
View count: 2