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

    simon.vergauwen

    08/02/2021, 5:03 PM
    Does anyone know if it’s possible to access
    kotlin.system.getTimeMillis
    from a custom source directory? I have a shared
    nativeMain
    module, on which all my native modules depend. I couldn’t find any
    std
    native lib I could depend on
    k
    m
    • 3
    • 3
  • j

    Justin

    08/07/2021, 3:23 AM
    When building a K/N library, do all varieties of Kotlin classes (i.e. data class/class/etc.) all get compiled into plain old obj-c classes? I ask because I am currently using a data class to represent a graph that stores a large amount of data (including nested data classes of various types), and performance on the macOS side - even just accessing instances of that class - becomes extremely slow as the number of nodes stored in an instance grows.
    m
    • 2
    • 1
  • a

    alex009

    08/07/2021, 4:59 PM
    hi all! we at IceRock release new gradle plugin for KMM - MOKO KSwift. With this plugin you can generate Swift-friendly API for Kotlin/Native framework. See examples in readme, in sample project and also you can read post on medium. Also you can extend logic of plugin inside your project - implement own generators of Swift code. Feel free to give feedback - here in thread or on github issues.
    :kotlin-intensifies: 12
    👍 5
    🙌 1
    :party-parrot: 4
    😒wift: 7
    a
    • 2
    • 2
  • n

    Napa Ram

    08/11/2021, 1:42 PM
    Hi Everyone, after using kotlin "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.20" i am facing issue while generating jacoco report Error i am getting
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:187)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:268) if downgrade the version to 1.4.21 then it's working fine
    e
    n
    • 3
    • 3
  • a

    Arslan Armanuly

    08/12/2021, 12:10 PM
    are there any example projects running c++ code using kotlin/native as a shared lib?
    b
    • 2
    • 10
  • n

    napperley

    08/13/2021, 3:36 AM
    There is a situation where I am stuck. With the libssh library I am trying to use the sftp_open function ( https://api.libssh.org/master/group__libssh__sftp.html#gaad64845af1100fb9325f20812f38da3b ), however the last function parameter (mode) seems to be expecting an octal literal (not entirely sure) which Kotlin doesn't support. Also the last function parameter involves doing a bit of bit banging (eg
    mode & ~umask
    ). It isn't clear how to do this with Kotlin since it doesn't provide any bit manipulation operators. Below is the binding for the function:
    @kotlinx.cinterop.internal.CCall public external fun sftp_open(session: libssh.sftp_session? /* = kotlinx.cinterop.CPointer<libssh.sftp_session_struct>? */, @kotlinx.cinterop.internal.CCall.CString file: kotlin.String?, accesstype: <http://kotlin.Int|kotlin.Int>, mode: libssh.mode_t /* = kotlin.UInt */): libssh.sftp_file? /* = kotlinx.cinterop.CPointer<libssh.sftp_file_struct>? */ { /* compiled code */ }
    e
    • 2
    • 2
  • s

    saket

    08/16/2021, 3:30 AM
    Is it expected that
    freeze()
    does not freeze items inside a collection?
    n
    k
    • 3
    • 5
  • n

    Nikolay Kasyanov

    08/16/2021, 10:35 AM
    Hey folks, quick question, is it expected that when I have this sealed hiearchy:
    sealed class Parent {
        object Child1: Parent()
        object Child2: Parent()
    }
    I still get
    Parent.init
    available in Objective-C/Swift, even though this class cannot be instantiated in Kotlin. Should I file a bug?
    d
    • 2
    • 6
  • b

    Big Chungus

    08/17/2021, 8:30 PM
    How do I check if the file exists by its relative path? e.g.
    existingDir/nonExistingDir/../existingFile
    always return false with both, access ans stat
    n
    • 2
    • 10
  • m

    Matthias Geisler

    08/18/2021, 10:51 AM
    Hey people - another day another question - I am currently try to hook in a dynamic Library from Swift into Kotlin...the Definition this far is fine...but the linker is not able to find the actual framework and after crawling for an answer...I did not find any good pointers...so I'd like to ask if anybody has some hints/advises/tutorials for hooking in a dynamic library (explicitly not static) into Kotlin for iOS?
    k
    • 2
    • 2
  • r

    ribesg

    08/18/2021, 11:25 AM
    So I updated IntelliJ IDEA and now I have lost completion and everything about my cinterops in IDEA. Anyone knows how to reliably get them back? I tried resetting everything and rebuilding a few times
    b
    b
    +2
    • 5
    • 25
  • k

    Kartik Prakash

    08/18/2021, 1:40 PM
    Is there any workaround to avoid
    @Throws
    annotation and handle the error on the native platform side. For example I have function in kotlin native that can throw
    SocketTimeoutException
    , Is there anyway to handle it on the iOS side without adding the
    @Throws
    annotation on my function?
    m
    • 2
    • 4
  • i

    Iaroslav Postovalov

    08/18/2021, 4:02 PM
    Hi! Is there a way to unsafely cast
    ULong
    to
    Double
    other than read/write it to
    ByteArray
    ?
    d
    • 2
    • 1
  • a

    aakira

    08/19/2021, 1:01 AM
    Is there any way to get backtrace on linux(linuxX64, linuxArm64....), wasm and mingw? For example, * Darwin
    NSThread.callStackSymbols
    * JVM
    Thread.currentThread().stackTrace
    n
    • 2
    • 2
  • b

    Bailey Pollard

    08/19/2021, 10:10 AM
    Where should we store PNG assets to access them from kotlin native ios?
    l
    s
    • 3
    • 7
  • c

    capitalthree

    08/20/2021, 3:00 AM
    I need to make a very simple http server in a kotlin native app (just for rpc with a webapp). I can't find any kotlin-native-ready http server libraries, so does anybody know of any, and if not, what would be the best choice for making a simple tcp listener in kotlin native (and I could slap together a simple http implementation that would be good enough for my purposes)?
    s
    b
    +2
    • 5
    • 17
  • w

    Wietlol

    08/20/2021, 2:00 PM
    is anyone aware of any plans for the concepts of project loom (mainly virtual threads with fibers) to be implemented in kotlin native? i am aware that it is not a simple copy paste operation and would be a big project to re-implement it, but the effective benefit of virtual threads is massive, so imo, it is certainly worth implementing
    b
    j
    +2
    • 5
    • 5
  • c

    Clocks

    08/21/2021, 5:35 PM
    I am having an issue building my cinterop library, below is the cinterop file I produced to bind
    glib
    . While it produces the bindings, When attempting to build I get the following error
    e: /home/doomsdayrs/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold invocation reported errors
    
    The /home/doomsdayrs/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold command returned non-zero exit code: 1.
    output:
    /home/doomsdayrs/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold: error: cannot find -lglib-2.0
    glib.def
    b
    • 2
    • 1
  • y

    Yaniv Sosnovsky

    08/22/2021, 1:03 PM
    Hi guys, has anyone ever encountered this error: ? including GitLiveApp/firebase-kotlin-sdk messed up my unit testing on iOS 😞
    > Task :ecCommunication:linkDebugTestIos FAILED
    e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
    The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
    output:
    ld: framework not found FirebaseFirestore
    Execution failed for task ':ecCommunication:linkDebugTestIos'.
    > Compilation finished with errors
    t
    • 2
    • 1
  • m

    magnumrocha

    08/23/2021, 2:35 PM
    does anyone can import the
    kotlinx.coroutines.newSingleThreadContext
    on kotlin native source folder?
    a
    t
    m
    • 4
    • 10
  • u

    吴少滨

    08/24/2021, 3:43 AM
    Are there any functions like finalize/dealloc in K/N Object?I have a CInterop delegate class like that.And When it's gone,I need to free the delegate pointer.
    class AssetExp {
        val delegate: CPointer<AssetModel>?
    
        constructor(){
            delegate = makeAssetModel()
        }
    
        //when Kotlin Object gone, call this functions
        fun finalize(){
            releaseVideoAssetModel(delegate)
        }
    }
    🇳🇴 1
    n
    c
    • 3
    • 14
  • l

    linjipeng

    08/24/2021, 8:53 AM
    I have create a class which is a subclass of NSNumber and I export it to Kotlin. When I invoke that object method , I found the type in runtime is changed to a class which is auto generated by kotlin multiplatform instead of my class. But if I let that class inherit from NSObject, everything will be all right. I wonder to know, what happened when I made it inherit from NSNumber.
    a
    • 2
    • 2
  • m

    Michal Klimczak

    08/24/2021, 2:36 PM
    What might that mean?
    /Users/teamcity3/buildAgent/work/290aee0e088a1666/runtime/src/main/cpp/ObjCExport.mm:276: runtime assert: Unexpected selector clash
    My app crashes with this error when something like this is invoked from swift code
    libraryManager.observeDownloadErrors()
    . What is also funny here, is that usually when I try to navigate to a kotlin method in xcode, it takes me to the shared.h file which is barely legible obj-c gibberish. But when I navigate from this particular method which crashes, it takes me to some Swift file (but is still definitely what I have defined in kotlin):
    public class LibraryManager : KotlinBase {
        open func observeDownloadErrors() -> KoruFlowWrapper<SomeKotlinException>
        ...
    }
    • 1
    • 2
  • m

    Michal Klimczak

    08/25/2021, 10:40 AM
    my ios tests stopped working with
    * Compiler version info: Konan: 1.5.21 / Kotlin: 1.5.21
     * Output kind: PROGRAM
    e: java.lang.UnsatisfiedLinkError: /Users/.../.konan/kotlin-native-prebuilt-macos-1.5.21/konan/nativelib/91439921922225643/libllvmstubs.dylib: dlopen(/Users/.../.konan/kotlin-native-prebuilt-macos-1.5.21/konan/nativelib/91439921922225643/libllvmstubs.dylib, 1): no suitable image found.  Did find:
    	/Users/.../.konan/kotlin-native-prebuilt-macos-1.5.21/konan/nativelib/91439921922225643/libllvmstubs.dylib: mach-o, but wrong architecture
    	/Users/.../.konan/kotlin-native-prebuilt-macos-1.5.21/konan/nativelib/91439921922225643/libllvmstubs.dylib: mach-o, but wrong architecture
    It's similar to this, but somehow it builds just fine for the ios app but fails for tests. Changing JDK didn't work either. I can;t go with 1.5.30-M1 yet (as per this comment)
    t
    • 2
    • 3
  • a

    Anton Afanasev

    08/26/2021, 12:42 PM
    Hi guys! I am wondering if K/N list implementation differ in any level from Kotlin Common. For instance:
    val mutableList = mutableListOf<Int>()
        val immutableList = mutableList.toList()
    Wondering if K/N handle
    toList
    method in some different manner? Does it use
    copy
    operation or simply check the type and cast as it does in stdlib?
    m
    • 2
    • 2
  • p

    ptmt

    08/26/2021, 1:37 PM
    Has anyone managed to successfully use K/N with the Xcode 13? I’m getting Cinterop error on 1.5.30:
    /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLSession.h:500:168: error: expected ')'
    • 1
    • 1
  • r

    russhwolf

    08/27/2021, 2:53 AM
    I’m having trouble building ios apps from commandline via xcodebuild when they import Kotlin code via the auto-generated embedAndSignAppleFrameworkForXcode task. Building from Xcode itself works fine, but if I do a command like this
    xcodebuild -sdk iphoneos -configuration Debug -workspace ./sample/app-ios/SettingsDemo.xcodeproj/project.xcworkspace -scheme SettingsDemo build
    then I get this error when hits that gradle task in the script phase
    A problem was found with the configuration of task ':shared:embedAndSignSharedAppleFrameworkForXcode' (type 'Copy').
      - Type 'Copy' property 'sign' doesn't have a configured value.
        
        Reason: This property isn't marked as optional and no value has been configured.
        
        Possible solutions:
          1. Assign a value to 'sign'.
          2. Mark property 'sign' as optional.
        
        Please refer to <https://docs.gradle.org/7.0/userguide/validation_problems.html#value_not_set> for more details about this problem.
    Does anyone have insight on what’s going wrong, or what else I can pass to xcodebuild to better mimic what’s happening when I build from the Xcode UI?
    • 1
    • 1
  • д

    Даниил Медведев

    08/27/2021, 7:27 PM
    How to compile K/N program with static linking? I not need link with local libc. I can compile as static library, then compile with C stub and use ld options for static build, but may be there's a more convenient way?
    ➕ 1
    👀 1
    b
    m
    • 3
    • 2
  • s

    spierce7

    08/27/2021, 10:31 PM
    I'm considering using Kotlin native to make an executable that wraps a C library and allows interfacing with it. Is there any reason that I should be wary of using Kotlin Native for this? I need to make executables that run on Mac and windows On x86 and arm.
    c
    u
    s
    • 4
    • 17
  • s

    spierce7

    08/28/2021, 6:14 AM
    I’m trying to use the c interop tool to generate the kotlin stubs for a c library. The Library is a dylib, and I have the header files.
    headers/mylibrary/mylibrary.h
    mylibrary.h references headers from another library,
    plist/plist.h
    . I also have these header files stored in
    headers/plist/plist.h
    , but for some reason no matter what I try, I can’t get the cinterop tool to find the plist.h headers. How can I fix this?
    • 1
    • 1
Powered by Linen
Title
s

spierce7

08/28/2021, 6:14 AM
I’m trying to use the c interop tool to generate the kotlin stubs for a c library. The Library is a dylib, and I have the header files.
headers/mylibrary/mylibrary.h
mylibrary.h references headers from another library,
plist/plist.h
. I also have these header files stored in
headers/plist/plist.h
, but for some reason no matter what I try, I can’t get the cinterop tool to find the plist.h headers. How can I fix this?
I got this working by using the Gradle api to include the header file root directory.
includeDirs(project.file("headers"))
View count: 4