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

    evant

    06/24/2019, 12:04 AM
    Came up with this
    -.rb
    y
    • 2
    • 2
  • e

    evant

    06/24/2019, 12:56 AM
    hm, running into another issue, it's failing to link on linux for some reason on circleci: https://circleci.com/gh/willowtreeapps/assertk/248 running it locally works fine, not sure what's different
    -.txt
    m
    • 2
    • 3
  • z

    Zh Efimenko

    06/24/2019, 11:12 AM
    Hi everyone, can anyone help me? If I throw exception in kotlin/native library. How can I handle exception in C code?
    a
    • 2
    • 2
  • s

    Slackbot

    06/24/2019, 1:32 PM
    This message was deleted.
    a
    • 2
    • 1
  • g

    galex

    06/25/2019, 7:54 AM
    Hello, my iOS team at work plans to switch to Swift Package Manager, is K/N compatible with this? We built a Kotlin multiplatform project that outputs an obj-C . Framework so I don't know if Swift Package Manager is only for Swift code or also Obj-C. Does someone know or have experience with Swift Package Manager?
    b
    s
    • 3
    • 6
  • a

    aljosa

    06/25/2019, 2:06 PM
    Anybody using Kotlin as a replacement for Obj-C/Swift? For example in MPP, where implementation for iOS platform would usually be written in Obj-C/Swift
    r
    s
    • 3
    • 14
  • s

    Sam Garfinkel

    06/25/2019, 2:19 PM
    Relocating the original post: Hey folks, does anyone know if there's a way to compile a multiplatform project via clang-cl or MSVC instead of MinGW? I'm trying to do some kotlin native development for Windows only, and I'd like to interop with https://github.com/microsoft/Detours which uses a few Microsoft extensions to C (such as
    __try
    for SEH) and a few MSVC preprocessor flags.
    l
    a
    • 3
    • 2
  • z

    Zh Efimenko

    06/25/2019, 2:58 PM
    How in C handle nullable pointer from kotlin native? I generate sharable library and use in C code. I return from Kotlin String? , in C header I have const char*. And I get an exception when I call method.
    o
    s
    • 3
    • 3
  • s

    Sam Garfinkel

    06/25/2019, 5:28 PM
    What is the correct way to replicate the behavior of a
    static void*
    attribute in Kotlin? Specifically a static reference to a function pointer. Does
    val foo = staticCFunction(::<FunName>)
    do this correctly?
    d
    • 2
    • 1
  • s

    Sam Garfinkel

    06/25/2019, 5:29 PM
    I have a CFunction that then takes a pointer to that pointer. So I actually need to do
    &(PVOID&)foo
    which is separately challenging me. PVOID is just an alias for void*. So I guess I need to figure out how to get the memory address of any particular CPointer (the actual pointer variable, not the pointed object).
    d
    k
    • 3
    • 10
  • b

    Benedict Pregler

    06/26/2019, 9:59 AM
    Hi, I created a new project and started with the Kotlin Mobile Android/iOS | Gradle example. But some things are red in the build.gradle and I can not build it because of
    Could not get unknown property 'ios' for KotlinTarget container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.
    My Kotlin Plugin Version is v1.3.40-release-IJ2019.1-1
    g
    a
    o
    • 4
    • 8
  • g

    gmaciel

    06/26/2019, 3:36 PM
    I've set it up a KN project running on android and ios (building the framework from within the xcode) and it works pretty well except for testing. I'm trying to have a test folder for common, android e ios but when i run the common tests it gets the actual from the android env. If i create a kotlin native ios/android project from intelliJ itself the tests work but i can't make it generate new framework from within xcode, which i managed to do with the manual setup. In the thread is my build.gradle
    s
    • 2
    • 14
  • m

    mben

    06/27/2019, 2:55 PM
    Hello i'm trying to define what is the different kotlin native use case in mobile development and i need to know if it is correct if i say that "kotlin native can be used in 2 ways the first one by creating shared library (.aar and .framework) for a code reuse purpose and the second way is to use it inside a project but still need to create a library to use it in ios side" ?
    s
    r
    • 3
    • 7
  • n

    napperley

    06/28/2019, 5:55 AM
    Cannot pass through a reference to a Kotlin function as a parameter. There seems to be a C interop mismatch with incorrect mapping files being generated for the Paho MQTT Client library ( https://www.eclipse.org/paho/clients/c/ ).
    s
    • 2
    • 5
  • d

    deactivateduser

    06/29/2019, 3:03 AM
    need help, how can i make dynamic c function ? fun g_callback(func: (CPointer<GtkWidget>?)->Unit): GCallback? = staticCFunction { widget: CPointer<GtkWidget>? -> println("kavan") func(widget) }.reinterpret()
    o
    • 2
    • 1
  • d

    deactivateduser

    06/29/2019, 10:55 AM
    If anyone intrested in building Kotlin Gtk library please contribute here. https://github.com/kavanmevada/kotlin-native-gtk-linux
    👍🏼 1
    d
    n
    g
    • 4
    • 11
  • f

    fcosta

    06/30/2019, 6:35 PM
    Pure swift libraries is supported by KN? I had to fallback to ObjC library with CocoaPods 😞
    s
    • 2
    • 5
  • a

    Arkadii Ivanov

    06/30/2019, 7:43 PM
    Unexpected behaviour found in K/N:
    val r = AtomicReference(1000L)
    val v = r.value
    println(r.compareAndSet(v, 2000L))
    The code above prints
    false
    . Line
    val v = r.value
    unboxes the value so
    compareAndSet
    is called with new instance of
    Long
    and fails. I am aware of
    AtomicLong
    , I'm trying to write some inline extensions for
    AtomicReference
    and they fail if type
    T
    is primitive.
    d
    o
    s
    • 4
    • 11
  • t

    Thomas

    07/01/2019, 9:31 AM
    Did anyone figure out how to use an expect/actual for
    java.lang.String.format
    and
    NSString.create(format, args)
    ? The
    NSString
    requires you to use
    *arrayOf(…)
    for args. For example let’s say this is the expect function:
    expect fun String.format(vararg args: Any?): String
    How would you able to make an actual fun using
    NSString.create
    ?
    s
    • 2
    • 6
  • l

    Lulu

    07/01/2019, 11:29 PM
    My gradle build have been failing with this error (on 1.3.40)
    Execution failed for task ':client:linkDebugTestLinuxX64'.
    > Process 'command '/opt/java/openjdk/bin/java'' finished with non-zero exit value 1
    Does anyone have an idea what that mean? Debugging wasn't that helpful.
    d
    s
    +3
    • 6
    • 72
  • t

    Thomas

    07/02/2019, 11:59 AM
    I’m trying to find a way to detect if a binary is debug or release, so I can disable/enable logging. I tried something like this:
    val commonMain by sourceSets.getting
    val iosMain by sourceSets.creating {
        dependsOn(commonMain)
        dependencies {
            // iOS dependencies
        }
    }
    val iosDebug by sourceSets.creating {
        dependsOn(iosMain)
    }
    val iosRelease by sourceSets.creating {
        dependsOn(iosMain)
    }
    targetFromPreset(iosTarget, "ios") {
        val debugCompilation = compilations.create("debug")
        val releaseCompilation = compilations.create("release")
    
        binaries {
            framework("common", listOf(DEBUG)) {
                compilation = debugCompilation
            }
            framework("common", listOf(RELEASE)) {
                compilation = releaseCompilation
            }
        }
    }
    I think this should work, I can use
    expect
    in iosMain and
    actual
    in iosDebug/iosRelease. However, the iosTest task I have throws an error it cannot find the
    actual
    implementation for the
    expect
    property. This is probably because the test uses iosMain instead of iosDebug. Is there a way to change that?
    r
    k
    • 3
    • 5
  • s

    spierce7

    07/02/2019, 6:26 PM
    Does the
    kotlin-platform-native
    plugin lack any features that the
    multiplatform
    plugin has? I know the platform-native plugin is considered deprecated, but my team just tried to swap to the
    multiplatform
    plugin, and we found several blocker bugs with the
    multiplatform
    plugin that stops us from swapping.
    i
    • 2
    • 3
  • m

    Marc Knaup

    07/02/2019, 7:21 PM
    Anything I need to be aware of if I use
    -Xdisable-phases=Devirtualization
    ? Performance penalty?
    m
    c
    • 3
    • 4
  • n

    napperley

    07/02/2019, 11:56 PM
    Keep on getting a segmentation fault when running the Kotlin Native program, and wonder if the macro wrapper (in the def file) is correct:
    # ...
    ---
    static inline MQTTClient_connectOptions createMqttConnectionOptions() {
        MQTTClient_connectOptions options = MQTTClient_connectOptions_initializer;
        return options;
    }
    m
    • 2
    • 8
  • g

    galex

    07/03/2019, 4:37 AM
    Hi, when building lately I get the following error. It’s probably something we wrote because a few commits before we managed to build the .Framework just fine. Any idea?
    -.kt
    a
    • 2
    • 4
  • n

    napperley

    07/03/2019, 10:26 PM
    What are the key things to be aware of with threads in Kotlin Native when it comes to C interop? Have a situation where a segmentation fault occurs when a callback (on the 2nd thread) is invoked by a C API (on the 1st thread which is the main thread?).
    d
    • 2
    • 9
  • n

    napperley

    07/03/2019, 11:30 PM
    The Kotlin Native mapping for the Paho MQTT Client library isn't aligned correctly. Take for example the MQTTClient_create function ( https://www.eclipse.org/paho/files/mqttdoc/MQTTClient/html/_m_q_t_t_client_8h.html#a9a0518d9ca924d12c1329dbe3de5f2b6 ) which takes four arguments. One of the arguments is handle which is a pointer to MQTTClient ( https://www.eclipse.org/paho/files/mqttdoc/MQTTClient/html/_m_q_t_t_client_8h.html#a7649e3913f9a216424d296f88a969c59 ). In the mapping the handle argument uses the CValuesRef<MQTTClientVar>? instead of CPointer<MQTTClient>?. Below is the MQTTClient_create function mapping:
    public fun MQTTClient_create(handle: kotlinx.cinterop.CValuesRef<paho_mqtt.MQTTClientVar /* = kotlinx.cinterop.CPointerVarOf<paho_mqtt.MQTTClient /* = kotlinx.cinterop.CPointer<out kotlinx.cinterop.CPointed> */> */>?, @kotlinx.cinterop.internal.CCall.CString serverURI: kotlin.String?, @kotlinx.cinterop.internal.CCall.CString clientId: kotlin.String?, persistence_type: <http://kotlin.Int|kotlin.Int>, persistence_context: kotlinx.cinterop.CValuesRef<*>?): <http://kotlin.Int|kotlin.Int> { /* compiled code */ }
    s
    • 2
    • 2
  • n

    napperley

    07/04/2019, 2:23 AM
    Is there a way to discover which character encoding is used? Some of the MQTT payloads have gibberish in them. Below is some sample output from the official Test Mosquitto server (a MQTT Broker), which is accessed from a Linux X64 PC:
    Message arrived.
    Topic Length: 0).
    Topic: some/test/ships
    Payload: {"lat":50.895,"lon":-1.391,"name":"ANGRY WASP","type":"sailing","typeno":36,"icon":"ship","iconColor":"lightblue","bearing":"300","speed":"0.0","destination":"","callsign":"MCMK9","layer":"AIS","time":"2019-07-04 02:16:34 UTC","ts":1562206594}
    
    Message arrived.
    Topic Length: 0).
    Topic: /golot7/kitchen/center/lampstatus
    Payload: 0
    
    Message arrived.
    Topic Length: 0).
    Topic: analytics
    Payload: {"name":"event.system.incoming.communication","date":1562206718325,"content":{"system.id":"08afb391512349019fc4462c69903138","communication.id":"45454545","message.id":"5b40f35036ad4a88afab6110b982a8d2","threadId":"18"}}2043����
    
    Message arrived.
    Topic Length: 0).
    Topic: /merakimv/Q2EV-2QFS-YRYE/light
    Payload: {"lux": 109.8}
    
    Message arrived.
    Topic Length: 0).
    Topic: analytics
    Payload: {"name":"event.system.incoming.communication","date":1562206718379,"content":{"system.id":"08afb391512349019fc4462c69903138","communication.id":"45454545","message.id":"77c19ab137e04c61b15f3cff2b816510","threadId":"7"}}":"20����A
    
    Message arrived.
    Topic Length: 0).
    Topic: rpi/rpi
    Payload: �?�3�A��s
                         |�
    g
    • 2
    • 1
  • a

    Alistair Sykes

    07/04/2019, 12:08 PM
    Hey, I am having an issue with the
    @Throws
    annotation. I have implemented it as described in this thread https://kotlinlang.slack.com/archives/C3SGXARS6/p1541595589233800. During
    :linkDebugTestIos
    I get an exception on a test class which is testing a method with the annotation.
    java.lang.IllegalStateException: Arrays of class literals are not supported yet
    Does anyone have any ideas about this? Any help would be greatly appreciated.
    s
    • 2
    • 1
  • t

    tylerwilson

    07/04/2019, 5:03 PM
    I am getting the following error at run-time when returning a response object from a network call after doing a JSON parse to my class:
    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[ReasonCompanion<0x10aea0210> init]: cannot init a class object.'
    Any clues as to what to look for?
    • 1
    • 1
Powered by Linen
Title
t

tylerwilson

07/04/2019, 5:03 PM
I am getting the following error at run-time when returning a response object from a network call after doing a JSON parse to my class:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[ReasonCompanion<0x10aea0210> init]: cannot init a class object.'
Any clues as to what to look for?
Never mind. Stupid bug in my ObjC code. I was not allocating a Kotlin companion member properly.
View count: 5