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

    nerses

    04/22/2020, 10:39 PM
    hey folks, first time trying Kotlin Native. Is Xcode mandatory for Kotlin Native ? I am trying to build the demo project https://github.com/kotlin-hands-on/intro-kotlin-native but I am getting
    23:30:05: Executing tasks ':assemble :macosMainBinaries :macosTestBinaries --stacktrace'...
    
    
    > Configure project :
    Kotlin Multiplatform Projects are an experimental feature.
    
    > Task :cinteropLibcurlMacos FAILED
    xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH
    Exception in thread "main" org.jetbrains.kotlin.konan.MissingXcodeException: An error occurred during an xcrun execution. Make sure that Xcode and its command line tools are properly installed.
    	at org.jetbrains.kotlin.konan.target.CurrentXcode.xcrun(Xcode.kt:77)
    	at org.jetbrains.kotlin.konan.target.CurrentXcode.access$xcrun(Xcode.kt:45)
    	at org.jetbrains.kotlin.konan.target.CurrentXcode$version$2.invoke(Xcode.kt:70)
    	at org.jetbrains.kotlin.konan.target.CurrentXcode$version$2.invoke(Xcode.kt:45)
    	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    	at org.jetbrains.kotlin.konan.target.CurrentXcode.getVersion(Xcode.kt)
    	at org.jetbrains.kotlin.konan.target.AppleConfigurablesImpl$xcodePartsProvider$2.invoke(Apple.kt:71)
    	at org.jetbrains.kotlin.konan.target.AppleConfigurablesImpl$xcodePartsProvider$2.invoke(Apple.kt:24)
    	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    	at org.jetbrains.kotlin.konan.target.AppleConfigurablesImpl.getXcodePartsProvider(Apple.kt)
    	at org.jetbrains.kotlin.konan.target.AppleConfigurablesImpl.getAbsoluteTargetToolchain(Apple.kt:48)
    	at org.jetbrains.kotlin.konan.target.ClangArgs.getAbsoluteTargetToolchain(ClangArgs.kt)
    	at org.jetbrains.kotlin.konan.target.ClangArgs.<init>(ClangArgs.kt:351)
    	at org.jetbrains.kotlin.konan.target.Platform$clang$2.invoke(Platform.kt:25)
    	at org.jetbrains.kotlin.konan.target.Platform$clang$2.invoke(Platform.kt:21)
    	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
    	at org.jetbrains.kotlin.konan.target.Platform.getClang(Platform.kt)
    	at org.jetbrains.kotlin.native.interop.tool.ToolConfig.<init>(ToolConfig.kt:37)
    	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.prepareTool(main.kt:377)
    	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:181)
    	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:46)
    	at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:44)
    	at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
    	at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:37)
    Caused by: org.jetbrains.kotlin.konan.KonanExternalToolFailure: The /usr/bin/xcrun command returned non-zero exit code: 72.
    output:
    
    	at org.jetbrains.kotlin.konan.exec.Command.handleExitCode(ExecuteCommand.kt:111)
    	at org.jetbrains.kotlin.konan.exec.Command.getResult(ExecuteCommand.kt:100)
    	at org.jetbrains.kotlin.konan.exec.Command.getOutputLines(ExecuteCommand.kt:79)
    	at org.jetbrains.kotlin.konan.exec.Command.getOutputLines$default(ExecuteCommand.kt:78)
    	at org.jetbrains.kotlin.konan.target.CurrentXcode.xcrun(Xcode.kt:75)
    	... 23 more
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':cinteropLibcurlMacos'.
    > Process 'command '/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
    I am confused as i can’t see anywhere in the docs Xcode as prerequisite.
    k
    m
    2 replies · 3 participants
  • k

    kevin.cianfarini

    04/22/2020, 11:19 PM
    Can we expect K/N compiler to update LLVM anytime soon?
    a
    2 replies · 2 participants
  • g

    gabin

    04/23/2020, 4:57 PM
    Hey guys. Why kotlin native supports only single-threaded code for coroutines? Is it temporary?
    k
    s
    +1
    9 replies · 4 participants
  • b

    basher

    04/23/2020, 10:01 PM
    Any thoughts on why this would happen only in K/N? https://youtrack.jetbrains.com/issue/KT-38540
    d
    3 replies · 2 participants
  • j

    Jamie Craane

    04/24/2020, 7:47 AM
    We have an issue with a Kotlin Native (KN) project when running a class from a JVM module results in a NoClassDefFoundError on a class from the common module. If we run this class using Gradle, the code runs without problems. I have re-created the issue in a sample project we use to test new things and can be found here: https://github.com/jcraane/KotlinNativeStarter The project structure is as follows:
    root
        android
            app (Android application)
        common (multiplatform module (common code, iOS, Android and JVM)
        buildSrc (some custom Gradle tasks)
        iosApp (The iOS application)
        jvmmodule (The JVM module, this is were it is all about)
        localization (some custom localization code for Android and iOS)
    The project is utilizing Kotlin 1.3.72 and Gradle 6.3. When checking out and importing the project into the IDE (Android Studio or IntelliJ) the problem is replicated by doing the following: Scenario 1 (running from the IDE) Actual: - Open the MyMainClass and click the Play icon in the gutter to execute the main method - The run window of the IDE outputs “Exception in thread “main” java.lang.NoClassDefFoundError: nl/jamiecraane/nativestarter/api/MockApi” Expected: - The main method is excuted and the response from the MockApi is displayed in the console Scenario 2 (running from Gradle) For this, we configured the Gradle application plugin to execute the MyMainClassKt. Run the following command from the command line: ./gradlew :jvmmodule:run The result of this execution is the following (as expected, without a NoClassDefFoundError)
    > Task :jvmmodule:run
    Hello
    Response data: [Person(firstName=Jan, lastName=Janssen), Person(firstName=John, lastName=Smith)]
    What can be the reason for this issue (NoClassDefFoundError when running the MyMainClass from the IDE instead of Gradle)?
    1 reply · 1 participant
  • s

    salomonbrys

    04/24/2020, 9:26 AM
    Untitled
    m
    7 replies · 2 participants
  • s

    Sam Garfinkel

    04/24/2020, 1:31 PM
    Why does the K/N target for Mac and iOS require the full Xcode suite, rather than just the command line tools? It’s a massive difference in size and I was hoping I could avoid installing the entire IDE.
    s
    1 reply · 2 participants
  • n

    nerses

    04/24/2020, 4:44 PM
    hi I have the following struct from kafka c lib
    typedef struct rd_kafka_message_s {
          ...
    	void   *payload;           /**< Producer: original message payload.
    				    * Consumer: Depends on the value of \c err :
    				    * - \c err==0: Message payload.
    				    * - \c err!=0: Error string */
    	size_t  len;               /**< Depends on the value of \c err :
    				    * - \c err==0: Message payload length
    				    * - \c err!=0: Error string length */
    	...
    } rd_kafka_message_t;
    I am struggling to figure out how to read the payload to a bytearray from Kotlin the interop binding gives me
    public final var payload: kotlinx.cinterop.COpaquePointer? /* = kotlinx.cinterop.CPointer<out kotlinx.cinterop.CPointed>? */
    
    public final var len: platform.posix.size_t /* = kotlin.ULong */
    d
    3 replies · 2 participants
  • a

    Alexander Larsson

    04/24/2020, 4:54 PM
    I’m having some trouble when adding methods and classes to a Swift library I’m calling from K/N. The new classes and methods won’t show up but the old ones work. Is there any way to force refresh the cinterop bindings or similar? (I build a new .framework and replace the old one and new Swift methods and classes are not accessible from K/N)
    k
    13 replies · 2 participants
  • d

    Daniel Berg

    04/25/2020, 8:21 PM
    This is more of a build question I guess. I'm trying to build a native target that uses ncurses. I've created a def file and tweaked binary target. I can see in the build that ncurses.kt file was created. What do I have to change in the build to start using ncurses in the commonMain source code?
    2 replies · 1 participant
  • r

    russhwolf

    04/26/2020, 1:10 AM
    I’m having trouble getting cinterop working on Linux. eg here’s a minimal repo trying to include sdbm directly from source. On macosX64 it builds fine, but on linuxX64 I get undefined symbol errors on linking. What am I missing?
    d
    s
    9 replies · 3 participants
  • j

    Jeff Beyond

    04/26/2020, 7:00 AM
    Hi, how can I check the current thread is main thread in Linux?
    m
    s
    3 replies · 3 participants
  • j

    Jeff Beyond

    04/26/2020, 12:23 PM
    I have anther problem. Is there any way to implement a mechanism on native like Handler.post(runnable) on android? when I accomplish the backend job in Worker, I want switch to calling thread (Main thread), Could anyone help me?
    m
    a
    +1
    13 replies · 4 participants
  • i

    ivan.savytskyi

    04/27/2020, 4:57 AM
    Hey folks question about https://kotlinlang.org/docs/reference/native/objc_interop.html#generics I know there are limitations but is list parameterized with nullable type is one of such limitation, I mean
    List<SomeType?>
    is translated to objectiveC / Swift as
    [Any]
    . @kpgalligan as far as I remember you were working on adding generics support, could you please advise?
    b
    s
    +1
    18 replies · 4 participants
  • p

    Patrick

    04/27/2020, 9:42 AM
    How would I specify in my gradle file that the code should be applicable to both the 64 bit and the 32 bit version of windows?
    a
    1 reply · 2 participants
  • j

    Jeff Beyond

    04/27/2020, 2:38 PM
    When I execute the task compileKotlinMacosX64,I get the errors below: • Unresolved reference: __syscall_slong_t • Unresolved reference: __time_t • Unresolved reference: pthread_condattr_setclock • Unresolved reference: pthread_condattr_setclock • Unresolved reference: __time_t • Unresolved reference: __syscall_slong_t • Unresolved reference: __syscall_slong_t  the errors occured in naitveMain module, I use some posix APIs in my code, and I config both macosX64Main and linuxX64Main dependsOn nativeMain Am I doing something wrong?
    a
    1 reply · 2 participants
  • r

    Rostislav Utrobin

    04/28/2020, 4:23 AM
    When I’m trying to build this sample from Xcode https://github.com/JetBrains/kotlin-native/tree/master/samples/cocoapods I’m getting an error. Do you have an idea what am i do wrong?
    Untitled
    a
    12 replies · 2 participants
  • p

    Patrick

    04/28/2020, 7:39 AM
    Does anyone know a good way how to do a timeout in a worker? How do I cancel the worker job without cancelling the worker itself?
    m
    8 replies · 2 participants
  • a

    Alexander Larsson

    04/28/2020, 1:43 PM
    Does anyone know how I can convert a
    CFStringRefVar
    to a Kotlin
    String
    ?
    a
    4 replies · 2 participants
  • o

    Omar Mainegra

    04/28/2020, 8:25 PM
    Hi everyone, I get different results using
    cos
    function in K/N, i.e:
    @Test
    fun cosine_functions_works_the_same_in_all_platform() {
        assertEquals(0.6441559905471732, cos(0.8708769899641021))
    }
    This test pass in JVM and JS, but fails in iOS:
    kotlin.AssertionError: Expected <0.6441559905471732>, actual <0.6441559905471733>.
    k
    n
    12 replies · 3 participants
  • n

    napperley

    04/28/2020, 10:20 PM
    How does C library dependency resolution work in Kotlin Native?
    3 replies · 1 participant
  • j

    Jeff Beyond

    04/29/2020, 10:24 AM
    Hi, when I compile the task linkDebugSharedLinuxX64, I get the error below:
    Produced library API in libkn_xxx_api.h
    e: /home/jeff/.konan/dependencies/clang-llvm-8.0.0-linux-x86-64/bin/ld.lld invocation reported errors
    The /home/jeff/.konan/dependencies/clang-llvm-8.0.0-linux-x86-64/bin/ld.lld command returned non-zero exit code: 1.
    output:
    ld.lld: error: unable to find library -lcurl
    Task :effectmanager:linkDebugSharedLinuxX64 FAILED
    FAILURE: Build failed with an exception.
    Anyone who knows how to solve it?
    m
    5 replies · 2 participants
  • a

    akapanina

    04/29/2020, 12:03 PM
    Hi folks! I wonder if someone in this chat uses Kotlin/Native arm32/arm64 target to compile code for Android. If yes - could you please share your case with me in direct messages - or here in the thread? Thanks!
    n
    r
    4 replies · 3 participants
  • p

    Prateek Grover

    04/29/2020, 5:49 PM
    Hey Guys. I was using Kotlin 1.3.61, with coroutines 1.3.2-native-mt-1 and serialization 0.14.0 I just updated to Kotlin 1.3.71, coroutines 1.3.5-native-mt and serialization 0.20.0 and getting this error when I build for iOS framework Please help
    e: Cannot access class 'kotlin.Pair'. Check your module classpath for missing or conflicting dependencies
    e: Cannot access class 'kotlinx.coroutines.CoroutineExceptionHandler'. Check your module classpath for missing or conflicting dependencies
    e: Cannot access class 'kotlin.collections.HashMap'. Check your module classpath for missing or conflicting dependencies
    o
    7 replies · 2 participants
  • o

    Omar Mainegra

    04/29/2020, 8:15 PM
    Hi folks, I'm writing some tests and I need a way to post operations to the main queue and make the test case wait for the queue to be empty before finishing (What I tried to do the the 
    sleep
     without success)
    @Test
    fun `This test doesn't execute the println statement`() {
        dispatch_async(dispatch_get_main_queue()) {
            println("dispatch_async")
        }
    
        NSThread.sleepForTimeInterval(1.0)
    }
    I'm thinking about something similar to
    XCTestExpectation
    . Any thoughts?
    k
    17 replies · 2 participants
  • p

    Prateek Grover

    04/29/2020, 9:55 PM
    Hey I am facing an error while building my project with new kotlin version 1.3.71 and the associated libs.
    e: Cannot access class 'kotlinx.coroutines.CoroutineExceptionHandler'. Check your module classpath for missing or conflicting dependencies
    I have created a small reproducible project with two branches. master that does not build and gives an error and working-old-version that builds successful. The only difference between the two branches is the versions of libs. https://github.com/kerry/kn-multilib To run the build
    SDK_NAME=iphoneos-hello ./gradlew :analytics:build
    Can someone help?
    o
    5 replies · 2 participants
  • n

    napperley

    04/30/2020, 1:00 AM
    Hypothetically speaking If the Kotlin Native team were doing third party Kotlin Native wrappers for the GObject libraries (GTK, Pango, Cairo etc) how would they do it (including handling complex C library dependencies)? GTK is well known for having complex C library dependencies, which are so complex that it isn't possible to statically link GTK itself.
    d
    17 replies · 2 participants
  • k

    Kavan

    04/30/2020, 4:22 AM
    Is Kotlin native copy hard coded or reference is passed ? when
    val s1 = "hello"
    var s2 = s1
    And can anyone explain data race conditions in Kotlin ? Is there brief explanation what's going on under the hood
    g
    3 replies · 2 participants
  • m

    mikehearn

    04/30/2020, 9:38 AM
    Does it use the DCE/garbage collection pass in
    ld
    ? that's a common trick for deleting unused code. It basically removes symbols that have no references from other symbols
    n
    3 replies · 2 participants
  • m

    mikehearn

    04/30/2020, 9:38 AM
    So far I got a Hello World app to 128kb using UPX
    n
    2 replies · 2 participants
Powered by Linen
Title
m

mikehearn

04/30/2020, 9:38 AM
So far I got a Hello World app to 128kb using UPX
n

napperley

05/01/2020, 1:58 AM
Is the project publicly available (through GitLab or GitHub)?
m

mikehearn

05/13/2020, 2:41 PM
No, it's literally println("Hello World")
😐 1
View count: 7