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
multiplatform
  • s

    serebit

    08/02/2020, 3:19 AM
    Thanks to mainline HMPP support in 1.4, my project Logkat can now support every single Linux target currently available with barely any duplicated code! Unfortunately, though, IDEA doesn't seem to have gotten the memo, and still marks all platform declarations in the shared source sets as errors (even though the Kotlin compiler is just fine with them).
    👍 3
    b
    s
    l
    • 4
    • 19
  • j

    John O'Reilly

    08/02/2020, 8:35 PM
    I'm using version
    1.3.8-native-mt-1.4.0-rc
    of kotlinx coroutines....but right now need to use the non
    native-mt
    version for macOs target....in pre-1.4 (before "hierarchical project structure" support I could add appropriate strict version setting in gradle....is there any recommended way to do that now (tried a few options but doesn't seem to work for some reason)?
    👍 1
    • 1
    • 1
  • e

    edenman

    08/04/2020, 2:49 AM
    I’ve gotten AS into some sort of state where it’s not recognizing that I have a KMP setup, showing all
    actual
    declaration as an error `The feature "multi platform projects" is experimental and should be enabled explicitly`…anybody else seeing this? AGP 4.2.0-alpha07, kotlin 1.4.0-rc, kotlin AS plugin 1.4.0-rc-release-Studio4.1-2
    a
    l
    • 3
    • 13
  • m

    Mgj

    08/04/2020, 2:07 PM
    Anyone here used https://github.com/icerockdev/moko-resources ? It seems very neat, but i'm having issues adding it to my project. I get the error:
    A problem occurred evaluating project ':app'.
    > Failed to apply plugin [id 'dev.icerock.mobile.multiplatform-resources']
       > Could not create plugin of type 'MultiplatformResourcesPlugin'.
          > Could not generate a decorated class for type MultiplatformResourcesPlugin.
             > org/jetbrains/kotlin/gradle/plugin/KotlinSourceSet
    when i try to apply the plugin:
    apply plugin: 'dev.icerock.mobile.multiplatform-resources'
    I've tried moving it around in my gradle file, but no luck
    n
    • 2
    • 3
  • a

    Alberto

    08/04/2020, 3:36 PM
    what is the recommended way of achieving callbacks in Kotlin Multiplatform? Via coroutines?
    z
    s
    +3
    • 6
    • 21
  • s

    serebit

    08/04/2020, 4:47 PM
    Okay, this is bizarre. With 1.4.0-rc in my project https://gitlab.com/serebit/logkat, if I attempt to compile from scratch with an empty
    .konan
    directory, it seems to try compiling some of the targets before their dependencies are done downloading.
    l
    • 2
    • 6
  • z

    zsperske

    08/04/2020, 6:36 PM
    Does anyone have any recommended guides or examples of setting up CI with a KMP project? I'm pretty new to CI in general so even basic tips would be appreciated.
    r
    • 2
    • 1
  • b

    Brandon Saunders

    08/05/2020, 10:13 AM
    does anyone here know why splitChunks in the webpack definition on a multiplatform project that targets JS would cause the output to no longer go to the distributions folder? If I add the following to my webpack config
    config.optimization.splitChunks = {
        minSize: <someNumber>,
        maxSize: <theSameNumber>
     };
    I get nothing in my distributions folder. If I remove it, the distributions folder gets created on build. Any ideas?
    a
    • 2
    • 4
  • a

    andylamax

    08/05/2020, 3:34 PM
    IntelliJ highlighs dependencies in red when using
    kotlin("js")
    . But the code compiles just fine. However when using
    kotlin("multiplatform")
    the dependencies are resolved well for all targets including
    js
    . I don't want to add the
    kotlin("multiplatform")
    plugin as this is a JS only library, any current work arroud?
    l
    • 2
    • 1
  • s

    Slackbot

    08/05/2020, 4:52 PM
    This message was deleted.
    s
    • 2
    • 1
  • a

    andylamax

    08/05/2020, 9:19 PM
    I have found something so wiered and it goes as follows. I have a multiplatform lib called
    theme-core
    which at the moment, targets
    js
    jvm
    and
    android
    . I also have a pure js library
    theme-react
    which depends on
    theme core
    .
    theme-react
    being a purely
    js
    lib. It has it's sources located at
    src/main/kotlin
    while
    theme-core
    sources for targeting js are at
    src/jsMain/kotlin
    I am trying to use
    theme-react
    and ultimately
    theme-core
    as a dependency to a pure js react ui library called
    enteprise-react
    . as always sources are located at
    src/main/kotlin
    Idea is able to resolve
    theme-react
    sources but can't resolve
    theme-core
    sources. After being bugged by this for a while, I tried changing my
    build.gradle.kts
    like so
    sourceSets {
        val jsMain by creating {
            dependencies {
                api(project(":theme-core"))
                api(project(":theme-react"))
            }
        }
    
        val main by getting {
            dependsOn(jsMain)
            dependencies {
                api(kotlin("stdlib-js"))
                api("org.jetbrains.kotlinx:kotlinx-react:${versions.kotlinjs.react}")
                api("org.jetbrains:kotlin-styled:${versions.kotlinjs.styled}")
                api("org.jetbrains:kotlin-css-js:${versions.kotlinjs.css}")
            }
        }
    }
    so now
    enterprise-react
    has two sourceSets.
    jsMain
    and
    main
    . If I put my sources in
    jsMain
    all pure js libraries (including
    kotlin-react
    and
    kotlin-styled
    ) aren't resolved by IDEA. If I put my sources in
    main
    IDEA failes to resolve all dependencies build from the sources of the subprojects at
    jsMain
    (i.e.
    theme-core
    ) and all other mpp supprojects. I tried seperating my sources, no luck. as there is a moment I need resources from both
    theme-core
    and
    kotlin-react
    . Has anyone experienced this issue at all? any workaround suggestions please . . . Thank you in advance
    s
    • 2
    • 3
  • e

    edenman

    08/05/2020, 9:41 PM
    if i have an
    expect
    in the commonMain sourceset and an
    actual
    in my
    androidMain
    sourceset, is there any way to provide a different
    actual
    in
    androidTest
    ?
    a
    • 2
    • 1
  • z

    zsperske

    08/05/2020, 10:15 PM
    Does anyone have a favorite logging library for JVM/JS/Native?
    e
    c
    +2
    • 5
    • 5
  • p

    patjackson52

    08/07/2020, 4:08 PM
    Are there any known bugs with 1.4.0-rc & publishing/dependency resolution? I’m getting a build error when adding a dep with the follow:
    The consumer was configured to find a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common'. However we cannot choose between the following variants of:
    it then proceeds to list all of the variants. When looking at the module file there is only one artifact with type ‘org.jetbrains.kotlin.platform.type’ (the metadata module). Anyone else seeing this?
    n
    • 2
    • 8
  • i

    ivan.savytskyi

    08/07/2020, 9:12 PM
    Hey folks, does anyone sees the same issue after upgrading IDEA to the latest 2020.2. I have a Kotlin module that depends on native module. With latest update, IDEA started to complain
    Unresolved  reference
    for any class defined in
    commonMain
    folder. Project perfectly compiles via command line so this issue seems IDEA specific. Invalidating cache doesn't help.
    l
    t
    m
    • 4
    • 9
  • p

    Prateek Grover

    08/09/2020, 1:48 AM
    Kotlin Native Framework Size problem I am creating a Kotlin Native framework for iOS without using cocoapods plugin. Here is the minimal code to show the problem. https://github.com/kerry/kn-library The problem is that it creates a framework of 17MB size on disk. Can someone explain if this is normal?
    a
    • 2
    • 9
  • n

    Nikky

    08/09/2020, 5:44 PM
    i am looking for tutorials about how to do bintray publishing of multiplatform projects.. my library only depends on the serialization-runtime and reflect and i plan to public to desktop platforms and jvm for now can anyone point me to a minimalistic example ? ideally using gradle-kts, but i can translate groovy if needed
    a
    m
    +3
    • 6
    • 11
  • d

    Daniele B

    08/10/2020, 7:37 PM
    I have a pre-populated sqlite database, I want to use as read-only. What is the best way to use it in the common section of a multiplaform app? Does anyone has a specific article to link me to?
    k
    • 2
    • 1
  • d

    Daniele B

    08/10/2020, 7:39 PM
    Does SqlDelight also work with pre-populated databases?
    k
    s
    • 3
    • 39
  • y

    yousefa2

    08/11/2020, 1:51 PM
    Hey everyone, I have this issue (https://youtrack.jetbrains.com/issue/KT-40976) when invoking suspending functions from Swift code. Does anyone see the same issue?
    r
    • 2
    • 3
  • a

    Alberto

    08/11/2020, 8:23 PM
    When adding a dependency to a specific platform, is it expected that the other variants increase size as well? As an example, I've tried adding AndroidX Lifecycle dependencies to the Android variant only, but I'm seeing the output binaries of iOS increase as well.
    l
    • 2
    • 1
  • z

    zsperske

    08/12/2020, 4:36 PM
    Noob question, can you develop an iOS using KMP with AppCode?
    t
    d
    • 3
    • 2
  • s

    saket

    08/12/2020, 5:32 PM
    with swiftUI there are very few reasons to use xcode anymore
    r
    • 2
    • 6
  • j

    John O'Reilly

    08/12/2020, 6:08 PM
    I'm trying out the new 1.4 capability of being able to call
    suspend
    functions (that use Ktor) directly from iOS client but running in to a few issues (thread)...
    r
    k
    k
    • 4
    • 23
  • a

    aleksey.tomin

    08/13/2020, 6:14 AM
    I try to migrate my MP multi-module project to 1.4-RC The root module has no code. On
    ./gradlew tasks
    see error
    Please initialize at least one Kotlin target in 'my-project (:)'.
    What I need to do? On 1.3.72 all OK. --info and --debug doesn’t help me. macOS, KMP contains OSX/minGW/android code gradle 6.4, 6.5.1 or 6.6, jdk - 1.8 or 11 - result the same PS: Solved - just add into root
    build.gradle.kts
    kotlin {
        jvm()
    }
    Thanks for @msink
    g
    m
    n
    • 4
    • 20
  • s

    Samuel Bichsel

    08/13/2020, 8:37 AM
    I am trying to export a Kotlin Native dependency to Swift through cocooapods. How can I achieve that? My build.gradle looks like that:
    targets {
            targetFromPreset(presets.android, "android")
    
            final def iOSTarget = project.findProperty("kotlin.native.cocoapods.target") == "ios_arm"    \
                                     ? presets.iosArm64 : presets.iosX64
    
            fromPreset(iOSTarget, 'ios')
        }
    
        cocoapods {
            summary = "Shared Kotlin/Native module"
            homepage = "<https://github.com/dreipol>"
            frameworkName = "Shared"
        }
    I read in the documentation, that yore able to export it like that , but that doesn’t work with the cocoapods integration:
    fromPreset(iOSTarget, 'ios').binaries {
        framework {
            export "ch.dreipol:dreimultiplatform:$dreiMultiplatformVersion"
        }
    }
    Does anyone have a hint?
    y
    • 2
    • 1
  • n

    nrobi

    08/14/2020, 9:06 AM
    Does anyone have a simple KMP CI setup with an iOS build job?
    a
    m
    • 3
    • 5
  • w

    Will Hess

    08/14/2020, 7:46 PM
    Does anyone know why I would be having issues importing the
    import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
    task into my
    build.gradle
    file? I am trying to create a fat framework that can be consumed in my iOS sample application.
    k
    e
    i
    • 4
    • 12
  • p

    Peter Hsu

    08/15/2020, 7:33 AM
    I'm having issues getting coroutines launching on iOS on coroutines-1.3.5-native-mt. I'm getting the following error message when trying to run
    CoroutineScope(Dispatchers.Default).launch {
       ...
    }
    iOS output when calling from the main thread:
    kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one.
    I'm running on iOS simulator, would that be the issue? I suspected a dependency versioning issue, so I am forcing coroutines version to be 1.3.5-native-mt via gradle as it seemed to be being force back to 1.3.5 without it, using the following in my root gradle:
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == "org.jetbrains.kotlinx" &&
                    details.requested.name == "kotlinx-coroutines-core-common") {
                    details.useVersion("$coroutinesVer")
                }
                if (details.requested.group == "org.jetbrains.kotlinx" &&
                    details.requested.name == "kotlinx-coroutines-core") {
                    details.useVersion("$coroutinesVer")
                }
            }
        }
    }
    and my dependencies tasks indicate the proper libs are being pulled in now. I'm really confused why I'm getting this error message. It was my understand that 1.3.5-native-mt utilizes a single background thread for Dispatchers.Default.
    j
    a
    • 3
    • 5
  • d

    Davide Giuseppe Farella

    08/15/2020, 10:04 PM
    Hello, I’m trying to find a replacement for
    actor
    , for implement a debounce operator. On jvm I would write ( I’ll skip something for simplicity ) :
    val result = MutableStateFlow(emptyList<Movie>)
    
    val searchActor = scope.actor<String>(CONFLATED) {
      for (query in channel) {
        delay(250) // debounce
        result.value = searchMovie(query)
      }
    }
    
    // Outer world
    launch { result.collect { ... } }
    searchActor.send(query)
    What would be a nice solution on KMP? Thank you
    a
    • 2
    • 2
Powered by Linen
Title
d

Davide Giuseppe Farella

08/15/2020, 10:04 PM
Hello, I’m trying to find a replacement for
actor
, for implement a debounce operator. On jvm I would write ( I’ll skip something for simplicity ) :
val result = MutableStateFlow(emptyList<Movie>)

val searchActor = scope.actor<String>(CONFLATED) {
  for (query in channel) {
    delay(250) // debounce
    result.value = searchMovie(query)
  }
}

// Outer world
launch { result.collect { ... } }
searchActor.send(query)
What would be a nice solution on KMP? Thank you
a

Arkadii Ivanov

08/15/2020, 11:00 PM
Looks like MVI. Maybe MVIKotlin would help?
d

Davide Giuseppe Farella

08/15/2020, 11:30 PM
Thank you, that a very nice project and the time-travel is crazy, but I prefer to solve without any framework
View count: 7