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

    bmo

    03/04/2021, 8:36 AM
    Hello everyone, I'm trying to create a multi-module library in Kotlin Multiplatform to be used in iOS, Android and Web but I have issues with iOS. I created a stackoverflow post. If anyone can help, it would be greatly appreciated! https://stackoverflow.com/questions/66471115/how-to-make-a-multi-module-kotlin-multiplatform-library-for-ios
    a
    h
    • 3
    • 9
  • h

    HaiTrvn Lưu Trữ

    03/04/2021, 10:11 AM
    How to reuse model class (like: User::class) in backend module in KMM template?
    b
    m
    • 3
    • 7
  • b

    Ben Brugman

    03/04/2021, 1:03 PM
    Hello, as many others i am also new to this channel and i am looking for help. I have set-up everything and it works as expected and i can acces the shared folder from both apps (Android-Kotlin/iOS-Swift). My aim is to be able to acces app code during my automated ui test The current setup is that i made a Singleton in my shared module which contains a boolean (and other variables and methods). During my test run i want to set the Boolean to True When the method in the app is executed, it will check this Boolean wether or not is is True If the Boolean is True a method is used to assign values to the variables in the singleton Then in the continuation of the UITest i can acces those variables to validate stuff. Again most of it works, i can acces everything and it seems to work But, when the Singleton goes through Swift things go wrong, and it gives errors about frozen variables. The Annotation @Threadlocal takes this away. but then the end result is that the Singleton is instantiated twice and the values i am looking for are not stored in the Test run instance (.getInstance) Am i doing something wrong or is this the limitations (or strictness) of Swift? If anyone knows a better way i am also open to that because i believe Singletons are kind of frowned upon. I hope someone has done this successfully and can help me out, sorry for the long post.
    k
    • 2
    • 4
  • j

    jamieadkins95

    03/04/2021, 4:25 PM
    Hey everyone, we are looking to convert our internal sdks into multiplatform sdks so that the iOS team can use them as well. Our existing sdks are modularised by feature and by layer, so we have something that looks like this:
    content-data           football-data
         |                       |
         v                       v
    content-domain         football-domain
         \                       /
           \                   /
             \               /
               v           v
                  common
    (In reality we have 25+ sdks that sorta follow this dependency structure, and 15+ apps that use them to varying levels) When converted to KMM modules this works fine on Android. We declare the dependency on content-data and gradle will see the transitive dependency on content-domain and download that too. However on iOS when they bring the content-data framework in, ‘duplicate’ classes get prefixed with the library name. For example content-domain defines a
    DispatcherProvider
    interface that content-data provides an implementation of called
    DispatcherProviderImpl
    . In the iOS frameworks,
    DispatcherProvider
    gets generated as 2 different protocols:
    __attribute__((swift_name("DispatcherProvider")))
    @protocol Content_domain_kmmDispatcherProvider
    @required
    - (Content_domain_kmmKotlinx_coroutines_coreCoroutineDispatcher *)computation __attribute__((swift_name("computation()")));
    - (Content_domain_kmmKotlinx_coroutines_coreCoroutineDispatcher *)io __attribute__((swift_name("io()")));
    - (Content_domain_kmmKotlinx_coroutines_coreCoroutineDispatcher *)ui __attribute__((swift_name("ui()")));
    @end;
    and
    __attribute__((swift_name("Content_domain_kmmDispatcherProvider")))
    @protocol Content_data_kmmContent_domain_kmmDispatcherProvider
    @required
    - (Content_data_kmmKotlinx_coroutines_coreCoroutineDispatcher *)computation __attribute__((swift_name("computation()")));
    - (Content_data_kmmKotlinx_coroutines_coreCoroutineDispatcher *)io __attribute__((swift_name("io()")));
    - (Content_data_kmmKotlinx_coroutines_coreCoroutineDispatcher *)ui __attribute__((swift_name("ui()")));
    @end;
    Anywhere in content-domain that asks for a DispatcherProvider can’t take the implementation provided by content-data because it now implements a different interface/protocol This issue is also described in this post under subtitle ‘How well do the modules talk to each other?’ https://dev.to/touchlab/multiple-kotlin-frameworks-in-an-application-34e9 Q: Is the multiple sdk setup I’ve described possible with KMM? Is there any way around this, maybe by combining all the source sets into one before generating the iOS framework?
    r
    a
    • 3
    • 3
  • m

    Marko Novakovic

    03/04/2021, 9:46 PM
    can somebody give more perspective on KMP vs Flutter? I know can have specific use cases, like if you have Android app in Kotlin and you just extract common logic and build iOS UI instead of building if from 0 with Flutter. But! I would like to hear your take on production apps, stability, performance etc. For somebody debating which one to learn what would be your arguments for KMP and Flutter?
    a
    l
    u
    • 4
    • 5
  • d

    Derek Ellis

    03/05/2021, 1:31 AM
    I upgraded some dependencies and now when
    check
    is run
    compileDebugAndroidTestKotlinAndroid
    fails because it can't find the
    actual
    declaration for a JVM module. It worked before, and the actual declarations are there.. I can run
    testDebugUnitTest
    successfully too. Did something change or am I missing something obvious?
    g
    r
    q
    • 4
    • 10
  • c

    clark

    03/05/2021, 3:11 PM
    Has anyone been able to get the
    build.gradle.kts
    files generated by the KMM template to not be like entirely red?
    j
    e
    • 3
    • 6
  • g

    Gene Cahill

    03/05/2021, 5:03 PM
    I am working on a multi-platform project and in my commonTest it requires Robolectric test runner (i.e. @RunWith(Robolectric::class)) when running the android actual implementation. I’d like to get the benefit of having a single test execute for both android and ios targets without adding android dependencies to commonTest. Is there a clean way to do this?
    a
    • 2
    • 2
  • s

    Shannon Rhodes

    03/05/2021, 8:53 PM
    for targeting JS, do I have to use the @JsModule within my Kotlin code? when I compile using ./gradlew compileProductionExecutableKotlinJs my code only gives me the general JS functionality (objects, arrays, etc) not my actual module that I wrote in Kotlin.
    a
    • 2
    • 3
  • w

    william

    03/06/2021, 2:18 PM
    anyone have an example of using
    atomicfu
    in a multiplatform project for common code? having some trouble with it and could use a reference project
    o
    e
    • 3
    • 10
  • c

    clark

    03/06/2021, 8:51 PM
    Anybody know why only the
    androidMain
    and
    androidTest
    directories get treated like kotlin code in my KMM project? My
    commonMain
    doesn't get any autocomplete and can't find other packages I create inside of it UPDATE: Marking the
    kotlin
    directory within those directories made all of the intellisense features work.
    t
    a
    • 3
    • 4
  • c

    clark

    03/06/2021, 8:56 PM
    UPDATE: I was able to figure it out. I added all the folders as source folders in my project's
    shared.iml
    file
    b
    l
    • 3
    • 3
  • s

    Sebastian Peredo Murga

    03/06/2021, 9:34 PM
    Hello! I have a problem uploading to the App Store. Your support would help me a lot. I have detailed everything in this link https://stackoverflow.com/questions/66244025/kotlin-multiplatform-error-itms-90171-invalid-bundle-structure
    u
    l
    • 3
    • 3
  • l

    Lei Wu

    03/07/2021, 5:27 AM
    I have a pure java project, and it includes a jvm.jar that export by a KMP project, when I use some classes defined in the jvm.jar, the project will crash, the error message is “java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics” ... I guess there maybe need kotlin runtime, so I add this in KMP project’s gradle:  tasks._withType_<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { *  *kotlinOptions { *   *includeRuntime = true    noStdlib = false   } } but it not work, Is there anyone who could give some advice?
    e
    y
    • 3
    • 4
  • a

    Arkadii Ivanov

    03/07/2021, 11:57 AM
    A question about publishing to Maven Central. I have a library on GitHub and a publication setup via GitHub Actions. There are 5 jobs that publish different targets in parallel. The issue is that it creates multiple staging repositories in Nexus Repository Manager. So I have some questions: 1. Is it a problem at all? Maybe I should just close/release all the created repositories? 2. How people usually approach publications of MPP libs to Maven Central, specially if there are targets that must be built on different hosts (macOS/Windows/etc)
    👀 1
    b
    j
    m
    • 4
    • 16
  • s

    Shannon Duncan

    03/07/2021, 7:17 PM
    Question about multiplatform compiling the JVM jar. I know we need to include the stdlibs to use the jar directly in the JVM, however the instructions to include that are not very clear. I've found myriad of stack overflows but none of them using the kotlin dsl gradle. One promising post suggested adding
    compile("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
    however I don't know where in the build.gradle.kts file to put it. When running the jar in JVM right now I get the error :
    java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
    w
    • 2
    • 6
  • w

    william

    03/07/2021, 8:58 PM
    Hi all I am having trouble with an object getting frozen in its
    init
    block and then top level value assignments causing an exception. heres a min example:
    class Foo(bar: Bar) {
        init {
            CoroutineScope(Dispatchers.Default).launch { 
                bar.buzz()
            }
        }
        
        val a = 3
    }
    in the init block since bar is accessed, it seems like that is causing the entire foo object to also get frozen then when it gets to
    val a = 3
    during runtime - it complains about foo instance already being frozen. how can i go about fixing this?
    m
    r
    • 3
    • 11
  • e

    eygraber

    03/08/2021, 5:19 AM
    Is it expected that most things in Intellij/AS will be highlighted in red yet compile fine? For instance, anything used from a multiplatform library (coroutines, serialization, etc...) has an unresolved error, and pretty much every line in my gradle.kts files are red and say "Cannot access".
    🇳🇴 1
    🙌 1
    s
    b
    • 3
    • 18
  • d

    Daniele B

    03/08/2021, 2:51 PM
    I have seen in many multiplatform projects, global variables are defined in a Kotlin file inside a manually created
    buildSrc
    folder. Is there any reason to use that instead of just define them in the global gradle file
    buildscript
    section?
    j
    j
    e
    • 4
    • 6
  • s

    sushma nayak

    03/09/2021, 5:55 AM
    So, on KMM coroutines still run on main thread? Are there any problems in bigger mobile apps where we generally offload heavier tasks to background thread? I'm from iOS app development background and tried a POC on KMM with networking. There were no performance bottlenecks for the POC. But would love to have some perspective from bigger apps experience.
    a
    • 2
    • 1
  • a

    Abhishek Dewan

    03/09/2021, 7:33 AM
    Does anyone know how to resolve this issue. I started seeing it after adding KMM module to my application. I do have jcenter() added to the repositories section but still keep seeing it
    t
    • 2
    • 2
  • a

    Ashish Kumar Joy

    03/09/2021, 1:15 PM
    Hello all, We were trying to create a multiplatform library in our project, the idea is to create a npm package which can be publish and use from nodejs project and jar which can be used from Kotlin jvm project. What we observe that in js generated package we are getting dependency of "kotlin-test-js-runner" and "kotlin-test" as result when we are using the publish package we are getting "kotlin-test" and "kotlin-test-js-runner" as dependency which I think we dont require. Is there configuration I can do in multiplatform library so that generated js dont have these two dependencies. A sample code on github https://github.com/ashishkujoy/kotlin-js-jvm-library Thanks.
    b
    • 2
    • 9
  • s

    sushma nayak

    03/09/2021, 2:36 PM
    Any examples for testing common shared code in KMM?
    ➕ 1
    k
    m
    • 3
    • 7
  • a

    Ashish Kumar Joy

    03/10/2021, 6:58 AM
    Hi All is there any page which Kotlin is maintaining which gives indication regarding the timeline by when Kotlin/Js IR will be stable. We wants to use Kotlin/JS IR in our project but one concern we are getting from the clients is that Kotlin/JS IR is in alpha stage. We looked https://kotlinlang.org/docs/components-stability.html but that does not have indicative timeline. Any doc which Kotlin is maintaining for expected stability timeline for Kotlin/JS IR will help use back the decision of using it. Thanks
    r
    • 2
    • 2
  • a

    Andyeshiet

    03/10/2021, 11:34 AM
    hey, any got any great alternative for
    java.util.pattern
    trying to validate email
    y
    • 2
    • 1
  • b

    Ben Brugman

    03/10/2021, 12:32 PM
    Hi All, i was wondering if anyone of you successfully got Atomic value to work in the shared / commonMain. The import works but when i try to initialise a AtomicBoolean for instance i get an error. Where as if i try this in androidMain it works without error. Am i maybe missing a dependency in the commonMain to get it to work?
    m
    • 2
    • 3
  • k

    Kathrin Petrova

    03/10/2021, 3:35 PM
    Hi all! 👋 We are working to improve the experience of getting started with :kotlin: Kotlin for all newcomers, and we would value your feedback about our latest design. We invite mobile developers who plan to start using Kotlin Multiplatform Mobile or who have recently started using it to participate in a short study. The whole thing won’t take more than an hour. 👉 If you are interested, please fill out this form. With love, Kotlin Team.
    👍 3
    ❤️ 7
    a
    • 2
    • 1
  • j

    Jack Darlington

    03/10/2021, 5:25 PM
    I am trying to use cinterop with a custom declaration and it isn't being added into the kilb. Any ideas if there is anything else I need to do?
    • 1
    • 2
  • d

    Daniele B

    03/10/2021, 9:15 PM
    is there a way to define localized strings in an XML file in the CommonMain
    resources
    folder, and access the strings (just within the CommonMain, as it’s for a shared KMPViewModel) similarly to how it happens in Android?
    m
    d
    • 3
    • 4
  • e

    eygraber

    03/11/2021, 7:28 AM
    If I have an android and jvm("desktop") target, can I make another target that both of those will use for common jvm code?
    k
    r
    • 3
    • 5
Powered by Linen
Title
e

eygraber

03/11/2021, 7:28 AM
If I have an android and jvm("desktop") target, can I make another target that both of those will use for common jvm code?
k

Kris Wong

03/11/2021, 2:01 PM
"Sharing code between JVM and Android" is "postponed for later" on the kotlin roadmap
btw, you would make a shared source set in that case, not another target
r

russhwolf

03/11/2021, 2:07 PM
You can do this, but the IDE support probably won't work well. It'll build fine from Gradle if you can deal with red code in the IDE.
k

Kris Wong

03/11/2021, 2:10 PM
that can be quite challenging when code completion and navigation doesn't work for any JVM APIs
r

russhwolf

03/11/2021, 2:14 PM
Agreed. There's various workarounds but it doesn't really scale all that well. But it's not impossible to do.
View count: 3