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

    Slackbot

    02/09/2022, 4:08 PM
    This message was deleted.
    g
    m
    • 3
    • 2
  • v

    Vivek Modi

    02/09/2022, 6:55 PM
    Hey guys, I am learning kotlin Mutliplatform moblie. I am learning use of common module in ios application from the documentation. https://kotlinlang.org/docs/kmm-integrate-in-existing-app.html#connect-the-framework-to-your-ios-project What if we have pre-existing ios application. How can we use module code in ios application ? I didnt find this in document. Any guide would be great. Thanks
    m
    • 2
    • 1
  • l

    Landry Norris

    02/09/2022, 7:06 PM
    Is there a suggested way to provide an Android Context where needed in a multiplatform project? I'm using SQLDelight right now, which needs a context for creating a DB factory on Android, but not iOS or other platforms, but other libraries could have similar use cases in the future.
    t
    j
    t
    • 4
    • 7
  • e

    electrolobzik

    02/09/2022, 7:23 PM
    I want to setup multi module KMP project with one of the modules just having only common sources. Why have I to specify KMP target in that module? Actually I will not have any platform specific code there.
    m
    • 2
    • 3
  • s

    SooYoung

    02/09/2022, 10:11 PM
    Hello. I’m quite new to multiplatform development. I’m seeking an advice. I want my iOS and Android app to be able to fetch a json file from network and cache it on a device for the purpose of performance. Is there a multiplatform library doing that? I would appreciate any recommendation or advice.
    i
    c
    +2
    • 5
    • 14
  • l

    luciano_fabris

    02/09/2022, 11:35 PM
    Hi Everyone. Is it possible to create a pure npm library with KMP? Could you point me to some document where I can understand where are the artifacts generated? And how to consume them from another node package? Thanks in advance!
    l
    • 2
    • 1
  • t

    Tristan

    02/10/2022, 12:26 AM
    Hello, Is there an official documentation with a suggested architecture for KMP apps/libraries? I am currently trying to create a library. The documentation I use for reference is the one provided by the Android. This currently what I am doing
    my-project/
    ├─ shared/
    │  ├─ feature.domain.usecase/
    │  │  ├─ GetSomethingUseCase
    ├─ android/
    │  ├─ feature.domain.usecase/
    │  │  ├─ GetSomethingUseCaseImpl
    ├─ iOS/
    │  ├─ feature.domain.usecase/
    │  │  ├─ GetSomethingUseCaseImpl
    Where
    GetSomethingUseCase
    interface GetSomethingUseCase {
        operator fun invoke(): String
    }
    And Android
    GetSomethingUseCaseImpl
    class GetSomethingUseCaseImpl(private val context: Context) : GetSomethingUseCase {
        override operator fun invoke() = TODO("It uses the context.")
    }
    And iOS
    GetSomethingUseCaseImpl
    class GetSomethingUseCaseImpl(private val context: NSBundle) : GetSomethingUseCase {
        override operator fun invoke() = TODO("It does use something else.")
    }
    I am not sure I am doing it the correct way. Without expect/actual, I am loosing some tips, like “missing implementation” errors at compile time 😞
    c
    • 2
    • 2
  • c

    Charles Prado

    02/10/2022, 10:28 AM
    Hi. Is anyone else facing issues while distributing a KMM iOS app on Azure CI? My app presents no errors when I try to distribute it locally, but on CI it always says that the module shared wasn’t found (
    no such module 'shared'
    ). Can it be something related to the env config?
    t
    • 2
    • 1
  • g

    Gellért Biró

    02/10/2022, 10:33 AM
    Hey, Did anyone try to implement socket communication with
    Ktor
    ? Does it work on iOS as well?
    a
    • 2
    • 1
  • m

    Matt Nelson

    02/10/2022, 1:45 PM
    Anyone know how to import the
    -jvm
    variant of a kmp project module?
    // javafx sample module build.gradle.kts
    plugins {
        kotlin("jvm")
        application
        id("org.openjfx.javafxplugin") version("0.0.11")
    }
    
    // java/javafx/application configuration...
    
    dependencies {
        implementation(project(":multiplatform-module"))
    }
    The above keeps importing the
    -android
    variant of my
    :multiplatform-module
    😢
    :plus1: 1
    j
    • 2
    • 6
  • c

    CLOVIS

    02/10/2022, 5:27 PM
    I wonder if it's possible to exploit
    expect/actual
    into checking at compile-time if all endpoints are implemented. Eg, having a common module in which you declare the different endpoints, having a client-side module that depends on it and must implement all the endpoints, and the same server-side. The difficulty is that the implementation on the client-side and the server-side will not look the same at all, and the server-side needs to know the list of endpoints so they can be registered in Ktor
    h
    • 2
    • 1
  • j

    Jim

    02/10/2022, 7:32 PM
    I just noticed that on
    ./gradlew detekt
    the konan compiler is downloaded. Is there a way I can make native compiler downloads lazy? Furthermore I only have mingwX64 and macosX64, why is my jvm build runner that happens to be linux downloading linux platform compiler stuff?
    l
    • 2
    • 7
  • a

    adjpd

    02/10/2022, 9:23 PM
    Hi there. I'm guessing I can't just
    java.util.Date
    in the
    shared
    module under
    commonMain
    ? (I'm guessing this because the import fails, although I have other strange import failures)
    m
    • 2
    • 6
  • a

    adjpd

    02/10/2022, 11:24 PM
    When I start a new KMM project, add
    implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.2")
    to
    commonMain
    in my
    shared
    module, add
    Clock.System.now().epochSeconds
    in my
    Greeting
    file, then run the application in Android, it crashes with an error about not finding
    java.time.Instance
    .
    ✅ 1
    e
    • 2
    • 10
  • x

    xxfast

    02/11/2022, 2:19 AM
    why is there no
    commonDebug
    by default? whats the best way to create a dubug source set that links up correctly to android debug variant and ios debug configuration?
    :plus1: 1
    • 1
    • 3
  • c

    clark

    02/11/2022, 3:58 AM
    Is there a way to create a
    sqldelight
    DatabaseDriver
    for Android without requiring a context? I want all of my database work to be handled by shared code and I don't love having to instantiate it all by passing in an Android context
    m
    x
    • 3
    • 5
  • s

    Stefan Oltmann

    02/11/2022, 8:18 AM
    Is there a way to see how the generated
    equals()
    of my data class actually looks like? I needed to change it to a normal class and now in Swift it does not work anymore. So I try to find out what the original generated method does different.
    ✅ 1
    g
    e
    +2
    • 5
    • 8
  • j

    Jakub Sieprawski

    02/11/2022, 3:30 PM
    I am developing KMM library called edoLibrary used both on ios and android platforms. edoLibrary uses inside native modules responsible for video capture. On Ios platform video module called iosBiometry is added by c-interoperability. When I am publishing final edoLibrary binary and adding it to my ios project it also demands from me to add as a framework iosBiometry module with message: dyld: Library not loaded: @rpath/iosBiometry.framework/iosBiometry  Referenced from: /private/var/containers/Bundle/Application/5964BC21-66DB-4634-915A-450D647EC5E0/Multiplatform_Poc.app/Frameworks/edoLibrary.framework/edoLibrary  Reason: image not found Is there any way to export KMM shared module as umbrella framework containing all depended frameworks added by c-interoperability? I know that there is an export method but i don't know how to connect cinterop as a dependency. Or should I use cocoapods? below photo of iosBiometry c-interoperability and edoLibrary final native configuration.
    v
    a
    • 3
    • 9
  • k

    Kathrin Petrova

    02/11/2022, 4:44 PM
    🚀

     The first episode of the ATOM show▾

     is now available! ⚛️ A Touch of Multiplatform (ATOM) is a brand new monthly podcast dedicated to Kotlin Multiplatform, hosted by @touchlab_justin and me and produced by JetBrains and Touchlab! Check it out for Kotlin Multiplatform news and plans :kotlin-intensifies-purple: In the series premiere, we host @dsavvinov and @kpgalligan for a discussion of Multiplatform Mobile’s road to Beta and Compose Multiplatform. Feel free to share your ideas on the next topics and guests for ATOM in :thread-please: !
    🙌🏽 1
    ❤️ 9
    :kotlin-intensifies-purple: 15
    🙌 8
    a
    m
    n
    • 4
    • 3
  • l

    Landry Norris

    02/11/2022, 6:00 PM
    In one of my projects, I am using expect/actual for platform-specific behaviour. I now need my tests to be able to override this behaviour if possible (for example, having an actual class in both androidMain and androidTest). I would like the actual from the test source set to be used in tests, even in code in commonMain. Is this possible? When I define an actual class in androidTest, it complains that there's no expect declaration.
    a
    t
    • 3
    • 9
  • j

    jean

    02/11/2022, 10:18 PM
    I started a project as a multiplatform library with android and ios client in different folders but publishing new versions is quite cumbersome and I now would like to move to the “centralized” file architecture, like the one created by the kmm module. I tried to replicate how it’s done from a freshly created project but I keep getting this error
    Plugin [id: 'com.android.application'] was not found in any of the following sources:
    and nothing after. So gradle doesn’t understand that the
    buildscript
    block is now define in a different gradle file. I did include
    implementation(project(":shared"))
    in the gradle file at the android app level but still the same issue. Are there any non-gradle configuration changes to do I am not aware of?
    a
    • 2
    • 1
  • a

    adjpd

    02/11/2022, 11:04 PM
    I have a kotlin class that takes a
    suspend
    function as a constructor parameter. How can I call this in swift? I've attempted to pass a simple closure but it complains it doesn't conform to
    KotlinSuspendFunction0
    . Any idea on the correct swift syntax? My attempt in 🧵.
    h
    • 2
    • 9
  • a

    adjpd

    02/12/2022, 1:57 PM
    I have a kotlin function that uses a default parameter value. Is there any way of using this in the generated ios/swift code?
    h
    m
    • 3
    • 5
  • t

    theapache64

    02/13/2022, 1:26 AM
    [✅ SOLVED] How do I share fonts in a Compose Multiplatform library (Desktop and Android only) ? I am aware there’s a library to do this. But how do we achieve this without 3rd party lib?
    • 1
    • 1
  • a

    adjpd

    02/13/2022, 3:45 AM
    I have
    class
    that takes a
    suspend
    function,
    passedFn
    , as a parameter. And the class has a
    suspend
    method,
    fn()
    . When
    fn()
    calls
    passedFn()
    I receive this error on iOS
    illegal attempt to access non-shared Something.$fnCOROUTINE$0@2d9f788 from other thread.
    I'm vaguely aware it has something to do with freezing objects across threads. Could anyone enlighten me further? What would I need to do in order to get this to work?
    m
    • 2
    • 5
  • a

    adjpd

    02/13/2022, 9:03 PM
    I have a
    StateFlow
    that I'm collecting from swift. It works with a class that inherits from
    Kotlinx_coroutines_coreFlowCollector
    . But it's rather ugly. Is there are more concise way? Code in 🧵
    h
    j
    • 3
    • 5
  • k

    kierans777

    02/14/2022, 12:23 AM
    I'm trying to run my Kotest
    commonTest
    on iOS, however it doesn't look like any tests are run from the binary (
    text.kexe
    ). Looking at the output from
    $ ./gradlew iosX64Test --info
    and running
    xcrun
    myself I get
    $ /usr/bin/xcrun simctl spawn --standalone A92077C5-F953-4646-8FEE-C0F0A0C84C8F /Users/kieran/my-library/build/bin/iosX64/debugTest/test.kexe
    [==========] Running 0 tests from 0 test cases.
    [----------] Global test environment set-up.
    [----------] Global test environment tear-down
    [==========] 0 tests from 0 test cases ran. (0 ms total)
    [  PASSED  ] 0 tests.
    It works find for the JVM. My Gradle looks like:
    kotlin {
        jvm {
            compilations.all {
                kotlinOptions.jvmTarget = "1.8"
            }
            withJava()
            testRuns["test"].executionTask.configure {
                useJUnitPlatform()
            }
        }
    
        ios {
            binaries {
                framework {
                    baseName = "MyLibrary"
                }
            }
        }
    
        sourceSets {
            commonMain {
                dependencies {
                    api "io.arrow-kt:arrow-core:${rootProject.ext.arrowVersion}"
                    api "io.arrow-kt:arrow-fx-coroutines:${rootProject.ext.arrowVersion}"
                }
            }
    
            commonTest {
                dependencies {
                    implementation "io.kotest:kotest-framework-engine:${rootProject.ext.kotestVersion}"
                    implementation "io.kotest:kotest-assertions-core:${rootProject.ext.kotestVersion}"
                    implementation "io.kotest:kotest-property:${rootProject.ext.kotestVersion}"
                    implementation "io.kotest.extensions:kotest-assertions-arrow:1.1.0.98-SNAPSHOT"
                }
            }
    
            iosMain {
                dependsOn(commonMain)
                iosX64Main.dependsOn(it)
                iosArm64Main.dependsOn(it)
            }
    
            iosTest {
                dependsOn(commonTest)
                iosX64Test.dependsOn(it)
                iosArm64Test.dependsOn(it)
            }
    
            jvmTest {
                dependencies {
                    implementation "io.kotest:kotest-runner-junit5:${rootProject.ext.kotestVersion}"
                }
            }
        }
    }
    Am I missing something?
    e
    • 2
    • 3
  • s

    Sterling Albury

    02/14/2022, 7:13 AM
    In my kmp iOS app, I'm trying to create a
    Set<Foo>
    , where
    Foo
    is just a simple interface with a couple of functions defined in
    commonMain
    , and if I try to declare or instantiate this set in swift, I get the error "Type 'Foo' does not conform to protocol 'Hashable'". Is there a way to make my interface Hashable or is there another good way to have sets of my interface?
    p
    g
    r
    • 4
    • 16
  • j

    jean

    02/14/2022, 8:15 AM
    Where am I suppose to add custom maven repo configuration in a kmm project? I tried in
    build.gradle -> buildscript -> repositories
    ,
    build.gradle -> allprojects -> repositories
    ,
    settings.gradle -> pluginManagement -> repositories
    and
    shared -> build.gradle -> repositories
    but I always get the same error :
    Could not find com.jeantuffier😒tatemachine:1.5.0.
    Required by:
    project :shared
    p
    • 2
    • 3
  • a

    Alen Kirm

    02/14/2022, 3:42 PM
    Hey! Question regarding Data Binding/Flow. How do you usually handle that in KMM Project? For using Kotlin’s Flow type for example, we need to implement wrappers. Currently I am playing around with https://johnoreilly.dev/posts/kotlinmultiplatform-swift-combine_publisher-flow/. What about normal
    suspend
    functions? I’ve noticed you can call
    suspend/async
    Kotlin function inside Swift, and it is compiled into a completion closure. One downside I see there, is
    nullability
    and would be nice to have
    Swift's Result
    type in it for example. Any best practices regarding data flow in KMM project? 🙏
    j
    • 2
    • 2
Powered by Linen
Title
a

Alen Kirm

02/14/2022, 3:42 PM
Hey! Question regarding Data Binding/Flow. How do you usually handle that in KMM Project? For using Kotlin’s Flow type for example, we need to implement wrappers. Currently I am playing around with https://johnoreilly.dev/posts/kotlinmultiplatform-swift-combine_publisher-flow/. What about normal
suspend
functions? I’ve noticed you can call
suspend/async
Kotlin function inside Swift, and it is compiled into a completion closure. One downside I see there, is
nullability
and would be nice to have
Swift's Result
type in it for example. Any best practices regarding data flow in KMM project? 🙏
j

John O'Reilly

02/14/2022, 4:15 PM
Note that the following has emerged since I wrote that article and definitely recommend taking a look at it https://github.com/rickclephas/KMP-NativeCoroutines
👍🏻 1
a

Alen Kirm

02/15/2022, 8:03 AM
Hey @John O'Reilly! Came across this library few days ago. I’ll definitely check this one out again, and give it a shot. Thank you for your recommendation and your amazing blog posts! 💪
👍 1
View count: 25