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

    Marc Knaup

    06/11/2019, 6:44 PM
    How would I use a Ktor
    HttpClient
    in a background thread on iOS? The client needs to always be owned by the `Worker`'s thread and be accessible to all executions inside that worker 🤔 I basically need state in a
    Worker
    .
    o
    • 2
    • 7
  • m

    Marc Knaup

    06/11/2019, 7:31 PM
    Is the conflict resolution of KN deterministic when exporting to ObjC and there are collisions in class names? Initially: Kotlin
    mypackage.Url
    -> Swift
    Url
    Kotlin
    io.ktor.url.Url
    -> Swift
    Url_
    But now it has flipped and thus my Swift code doesn't compile anymore.
    s
    • 2
    • 1
  • l

    louiscad

    06/11/2019, 9:35 PM
    Is there any example of iOS library publishing that uses Gradle Kotlin DSL, and targets at least
    iosX64
    and
    iosArm64
    ?
    r
    m
    • 3
    • 16
  • j

    jwd83

    06/12/2019, 4:14 AM
    I was doing some research into Kotlin and saw it's supported by LLVM and I'm also tangentially aware of LLVM-AVR as a target for the ATMEGA 8 bit micros like those found in the Arduino Uno. I emailed the author of AVR LLVM and asked him about using the Kotlin/Native LLVM platform as an AVR-LLVM source. I'd be interested in developing C bindings for Kotlin/Native on AVR-LLVM if something like that is possible.
    m
    n
    d
    • 4
    • 14
  • z

    Zh Efimenko

    06/12/2019, 12:37 PM
    Who can help me with dll library. I generate it by kotlin native and want to use in c#. How can I get class with properties and methods, which is created in kotlin native?
    d
    • 2
    • 2
  • f

    Fail

    06/13/2019, 12:37 PM
    Hi devs! I create a new multiplatform project with Android and IOS. (It show a current platform) At android run perfectly but when I run the code on Xcode I have an error: /Users/.../Xcode/DerivedData/iosApp-axkbbwgyarknnvehlgjsmvkylxqc/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/app.build/Script-F861D812207FA4320085E80D.sh: line 2: /Users/dev/Documents/MultiplatformTest/iosApp/../gradlew: No such file or directory What a file I need? Where can get it?
    a
    • 2
    • 4
  • k

    Kruger Brent

    06/14/2019, 2:36 PM
    Does a C-library compiled with cinterop tool support Android app as well or is it just for the iOS app? If so, how would a build.gradle file look like that has a cinterop tag to build a klib file for both the platforms. I am unable to make this klib work for android right now. Any ideas?
    a
    p
    n
    • 4
    • 3
  • a

    Alexander Suslov

    06/14/2019, 8:07 PM
    I use K/N module (CoreModule) in my Android/IOs project. That module is depends on another MPP module (CommonModule), so I use this code in my gradle-file to make classes from CommonModule be visible in the swift code:
    binaries {
                    framework('CoreModule') {
                        export project(":CommonModule")
                    }
                }
    Now I'm trying to migrate to the new CocoaPods Gradle plugin but receive a
    Use of undeclared type '<class>'
    error for classes from CommonModule. I've tried to apply cocoapods plugin to CommonModule and import both frameworks to swift files but it didn't help - I got 2 versions of each of CommonModule's classes that are incompartible between each other. Is there any analogue for
    export(project(":exported"))
    instruction in the new CocoaPods Gradle plugin?
    m
    • 2
    • 3
  • t

    Thomas

    06/15/2019, 6:11 PM
    I found this example how to run unit tests on iOS: https://github.com/Kotlin/mpp-example/blob/0ace750ffd2ccb8dd4adf40f26b4d6ecc462c06a/greeting/build.gradle#L87-L99 If you are using the Kotlin/Native CocoaPods plugin, how can you run the tests? It is not possible to start this Gradle task as the executable needs to be built from Xcode. Can I somehow start this task from Xcode?
    • 1
    • 1
  • f

    fcosta

    06/16/2019, 2:13 PM
    Hi guys! I was trying to integrate cocoapods into my mpp project following the doc official documentation and I got the the below error. Any one know what does this mean?
    l
    • 2
    • 2
  • j

    Jan Stoltman

    06/16/2019, 9:10 PM
    Do flows work correctly in K/N? Are there any hidden pitfalls, anything like lack of multithreading in coroutines?
    l
    e
    • 3
    • 3
  • r

    Rostislav Utrobin

    06/17/2019, 5:44 AM
    Are there any ways to schedule an operation with some fire rate (timer)? I guess there is not option to do that in common module. Should I implement it via expect/actual (for native and jvm in my case)? The timer should work on a different thread, can i use Worker to do that? If answer is yes, how can i pass a lambda to the worker's execute method? Maybe there are good examples how to implement it?
    f
    u
    • 3
    • 4
  • z

    Zh Efimenko

    06/17/2019, 9:16 AM
    Hi everyone. Who can help me? I cannot understand how I can create and use object and C language after kotlin native generate library for native platform. I have a struct:
    typedef struct {
      libpst_KNativePtr pinned;
    } libpst_kref_kotlin_Array;
    And I have a function which get this object as parameter:
    libpst_KInt (*hash)(libpst_kref_com_tullynore_base_util_HashUtil thiz, libpst_kref_kotlin_Array values);
    a
    • 2
    • 4
  • j

    Jake

    06/17/2019, 4:13 PM
    Anyone have any experience utilizing a
    klib
    ? Or know of a good tutorial or more detailed documentation on the native libraries than I see on Jetbrains’ website? I’ve made a iOS framework with Kotlin Native, but there is a restriction they’ve created where you can only have one kotlin iOS framework in an app at a time. In an effort to modularize my shared code, I’d like to find a way to use several kotlin libraries in an iOS app at once. I believe for now I’ll need to create one Kotlin Native project that pulls in a bunch of libraries and spits out one bundled framework. But working with Gradle (not my forte) and this experimental stuff has got my head in a fog. Ex:
    Modules
    ----------
    Models feature A
    Models feature B
    Models feature C
    API-Client feature A
    API-Client feature B 
    Other Business Logic
    If our organization wants to use Feature B in another application I’d hate to have to pull all of that shared logic to the other app when I only want what matters to Feature B
    s
    • 2
    • 4
  • a

    andreasmattsson

    06/19/2019, 12:22 PM
    Is there an equivalent of
    @JvmName
    and/or
    @JvmMultifileClass
    for Kotlin Native? I have files with the same name in different sourcesets of a multiplatform project (e.g.
    common
    ,
    ios
    ,
    android
    ) and on iOS I end up with methods scattered under several different classes. (e.g.
    ServiceKt
    ,
    ServiceKt_
    ). Is this avoidable?
    k
    s
    • 3
    • 4
  • t

    Thomas

    06/19/2019, 2:26 PM
    I’m trying to include Coroutines 1.3.0-M1 with Kotlin 1.3.40 in my project. Coroutines 1.3.0-M1 is not based on 1.3.40 so I need to build it manually. I successfully built coroutines and published it to maven local. However, the generated objective C framework has the following error (my module is named common):
    Cannot find protocol declaration for 'CommonKotlinCoroutineContextElement'; did you mean 'CommonKotlinCoroutineContextKey'?
    This is the part where it shows the error:
    __attribute__((swift_name("KotlinCoroutineContext")))
    @protocol CommonKotlinCoroutineContext
    @required
    - (id _Nullable)foldInitial:(id _Nullable)initial operation:(id _Nullable (^)(id _Nullable, id<CommonKotlinCoroutineContextElement>))operation __attribute__((swift_name("fold(initial:operation:)")));
    - (id<CommonKotlinCoroutineContextElement> _Nullable)getKey:(id<CommonKotlinCoroutineContextKey>)key __attribute__((swift_name("get(key:)")));
    - (id<CommonKotlinCoroutineContext>)minusKeyKey:(id<CommonKotlinCoroutineContextKey>)key __attribute__((swift_name("minusKey(key:)")));
    - (id<CommonKotlinCoroutineContext>)plusContext:(id<CommonKotlinCoroutineContext>)context __attribute__((swift_name("plus(context:)")));
    @end;
    Could anyone here point me in the right direction what could be wrong?
    e
    s
    r
    • 4
    • 12
  • s

    serebit

    06/19/2019, 6:33 PM
    With 1.3.40 in one of my projects, I keep getting the error
    org.jetbrains.kotlin.konan.target.HostManager.<init>(Lorg/jetbrains/kotlin/konan/target/Distribution;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
    when attempting to assemble the project, or in fact run any Gradle task.
    l
    i
    • 3
    • 4
  • r

    redrield

    06/19/2019, 9:42 PM
    Am I able to cross compile Kotlin/Native to arbitrary targets? For instance with Rust (uses LLVM so it's a decent parallel) allows me to specify custom targets, and the linker to use with that target
    g
    • 2
    • 3
  • z

    Zh Efimenko

    06/20/2019, 10:29 AM
    Could anyone help me? I write native library. I have a header with struct, which has follow line:
    PstFile (*PstFile)(const char* filePath, const char* mode);
    When I call this constructor in C code I pass 2 string:
    PstFile.PstFile("/home/evgeni/Projects/SAGO/NLC/source.pst", "rb");
    But in my library I get another string:
    @&�9�
    and
    rb
    if I swap the parameters, I get another string:
    @���~
    and
    /home/evgeni/Projects/SAGO/NLC/source.pst
    . Why first parameter anyhow?
    a
    • 2
    • 7
  • f

    fcosta

    06/20/2019, 4:13 PM
    Hi guys! Am I able to run ios tests with
    CocoaPods
    ? The documentation says that if the module uses
    CocoaPods
    libraries, it can be build
    only from Xcode
    . 😞
    o
    s
    p
    • 4
    • 8
  • j

    Jake

    06/20/2019, 7:10 PM
    Does anyone know how to use a .klib like a dependency? If I wanted to use 1.klib and 2.klib in a project3 and spit out an iOS framework that contains all of the code from 1, 2, &3 is that possible?
    d
    • 2
    • 44
  • p

    pardom

    06/20/2019, 11:05 PM
    Has anyone tried kotlin native with Xcode 11 beta yet? I’m trying to use a framework with the cocoapods plugin and the header won’t compile.
    -.c
    s
    • 2
    • 7
  • k

    kpgalligan

    06/21/2019, 7:56 AM
    I forget how to look this up, but if anybody has the Xcode 11 beta, to use the Xcode debug we’ll need the Xcode UUID. I’m not installing Xcode 11 beta just yet, but if we can find that UUID I can add to debugger. See towards bottom: https://github.com/touchlab/xcode-kotlin/blob/master/Kotlin.ideplugin/Contents/Info.plist
    t
    k
    p
    • 4
    • 49
  • d

    Daniel Gergely

    06/21/2019, 2:53 PM
    Hey guys! For fun, I've translated my AI assignment, which is basically a BFS graph search to Kotlin, and then compiled and benchmarked its runtime using the same input, compiled with different compilers. As you can see it's not even magnitudes slower in K/N, but also much slower if I compile it with the latest version. Can somebody elaborate on this? (I'm using Windows btw)
    👍 2
    🤔 1
    o
    f
    k
    • 4
    • 8
  • j

    Jurriaan Mous

    06/22/2019, 8:40 AM
    After upgrading to Kotlin 1.3.40 I got a
    Compilation failed: GC overhead limit exceeded
    when running
    linkDebugTestMacos
    . How do I higher the memory limit for the task/project? I have tried
    org.gradle.jvmargs=-Xmx4g
    in the gradle.properties. I use gradle 5.1.1
    l
    t
    • 3
    • 4
  • t

    Thomas

    06/22/2019, 10:48 AM
    I’m getting the following exception when building. This happened after adding code to my project. I was able to narrow it down to a piece of code, but I cannot reproduce it in a sample project. Could anyone explain to me what this error means so I can find the cause? EDIT: I have enabled the new Objective C generics using
    -Xobjc-generics
    in my project. If I disable that then the issue is gone. Looks like this is a bug with the new generics.
    Untitled.txt
    d
    j
    s
    • 4
    • 7
  • l

    louiscad

    06/22/2019, 8:47 PM
    Is there any example out there using iOS/macOS
    NSNotificationCenter
    with Kotlin/Native?
    ☝️ 1
    r
    s
    s
    • 4
    • 12
  • j

    juancho

    06/23/2019, 3:31 PM
    Hi all! Not sure if it was already asked but is there any consideration to take into account if I want to publish an iOS app to the Apple Store using a framework generated from Kotlin Native? what about bitcode? Is there something special to set in the gradle config for this framework? I just want to avoid having issues with the App being rejected from Apple Store because the framework doesn’t comply something. Thoughts?
    l
    b
    +2
    • 5
    • 8
  • l

    louiscad

    06/23/2019, 8:26 PM
    I'm trying to integrate with
    NSObject
    observability, but I'm struggling to understand how this Objective-C method signature translates to Kotlin: https://developer.apple.com/documentation/objectivec/nsobject/1416553-observevalueforkeypath?language=objc It seems I need to declare it in an
    NSObject
    subclass for
    addObserver
    to work: https://developer.apple.com/documentation/objectivec/nsobject/1412787-addobserver?language=objc Can anyone help me?
    b
    • 2
    • 22
  • e

    evant

    06/23/2019, 11:03 PM
    I was using this task to run kotlin native tests on the ios simulator, but it looks like the link task is missing when updating to 1.3.40. Anyone know what this should be updated to?
    -.txt
    b
    r
    • 3
    • 3
Powered by Linen
Title
e

evant

06/23/2019, 11:03 PM
I was using this task to run kotlin native tests on the ios simulator, but it looks like the link task is missing when updating to 1.3.40. Anyone know what this should be updated to?
-.txt
b

basher

06/24/2019, 12:21 AM
I believe
linkTestDebugExecutableIosX64
is now
linkDebugTestIosX64
r

russhwolf

06/24/2019, 12:40 AM
Yeah
linkDebugTest<Name>
is correct as I understand it. Some versions of that setup also need to change usages of
binaries.getExecutable()
to
binaries.getTest()
but you might be fine assuming the test outputFile is still the same.
oh I guess you already got there judging by your next post
👍 1
View count: 7