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

    James Black

    04/07/2022, 3:37 AM
    I am trying to build a project with a Kotlin backend to show how this will work. In my shared build.gradle file I have this:
    kotlin {
        android()
        iosX64()
        iosArm64()
        iosSimulatorArm64()
        jvm()
    Near the end I have this:
    val jvmMain by getting {
                dependencies {
                    implementation("io.ktor:ktor-client-apache:${Versions.ktor}")
                }
            }
    
        }
    }
    
    android {
        compileSdk = 32
        sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
        defaultConfig {
            minSdk = 30
            targetSdk = 32
        }
    }
    
    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
        kotlinOptions {
            jvmTarget = JavaVersion.VERSION_11.toString()
            freeCompilerArgs = listOf("-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check",
                "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi", "-Xjvm-default=all"
            )
        }
    }
    It recognizes jvmMain as I had to include the expected functions. In my server build.gradle I have:
    import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
    plugins {
        kotlin("jvm")
        id("kotlin-platform-jvm")
        id("war")
        id("application")
        kotlin("plugin.serialization")
        id("kotlinx-serialization")
    }
    
    
    dependencies {
        implementation(project(":shared"))
    Snipped rest
    }
    
    kotlin {
        sourceSets.all {
            languageSettings {
                optIn("kotlin.RequiresOptIn")
            }
        }
    }
    
    java {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    When I look at anything from the shared project it goes to the androidMain version, not the jvmMain version. How do I get it to find the correct versions of the classes?
    • 1
    • 1
  • v

    vishal G

    04/07/2022, 9:11 AM
    Why using kodein is beneficial rather than using koin in KMM project?
    k
    c
    e
    • 4
    • 7
  • g

    Gellért Biró

    04/07/2022, 11:13 AM
    Is there a way in KMM to have a json config file in the shared part which we can be later read from both platforms?
    h
    d
    p
    • 4
    • 5
  • i

    Igor Kozlinskyi

    04/07/2022, 2:20 PM
    Hello! I have a question regarding the development process of KMP and Kotlin lang in general. First of all, I would like to say a big thank you to JetBrains team - the tools that you guys create are top-notch. I enjoy using them - be it an IDE or the Kotlin language. I also see that the development never stops and even if there are flaws/bugs - they get fixed fast, and each update makes the products only better. Currently the team I am working with is deciding on a tech stack for our upcoming mobile app, and the KMP/KMM looks very promising to us. We see that the multiplatform project is in alpha, but it is Ok to us assuming that the project is supported and we will be seeing new releases. There was a 1.6.20 version of Kotlin released just a couple of days ago, which is great! My biggest concern is - how is the development going on right now? From what I can tell many Kotlin lang developers are located in Russia. Did the teams manage to return to the same release-cycle tempo as previously? Or maybe there is a pause in development? Is it possible for some projects to be stopped at all? Anything of it is understandable assuming the circumstances. Also, I would like to add that I am very grateful for the clear position the company has taken regarding the war. I hope that everyone in JetBrains team is safe, wherever they are.
    :kotlin-intensifies: 14
    a
    • 2
    • 1
  • j

    Jeff Tycz

    04/08/2022, 1:23 AM
    Is it possible to create custom lint checks in a KMM project? I want to make a custom annotation and have the method/s that are annotated with my annotation highlighted in the IDE with a warning when it is used. Everything I have seen about custom lint checks is with normal android apps
    p
    m
    • 3
    • 3
  • i

    iamthevoid

    04/08/2022, 7:53 AM
    How do you encode and decode Base64 in common code? Looks like this contains in ktor, but it is marked as InternalApi
    a
    n
    +4
    • 7
    • 11
  • l

    Lucas Schiavini

    04/08/2022, 3:09 PM
    Anyone had problems using kotlin classes on a thread in swift, and having errors like : Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared <object>@27c0f38 from other thread And after trying to annotate the class with either SharedImmutable or ThreadLocal getting -> @ThreadLocal is applicable only to property with backing field, to property with delegation or to objects
    k
    p
    • 3
    • 4
  • p

    pguardiola

    04/08/2022, 8:14 PM
    ok this is something
    Uncaught Kotlin exception: kotlin.IllegalStateException: There is no event loop. Use runBlocking { ... } to start one.
    :thread-please: 1
    k
    • 2
    • 2
  • p

    pguardiola

    04/08/2022, 8:21 PM
    ohh maybe i misread
    Coroutines 1.7.0 will be released without
    native-mt
    companion and we are gradually stopping the support of
    native-mt
    during the course of
    1.6.x
    lifecycle. We still are ready to accept PRs or release versions with the new Kotlin if there is a need to, but new coroutine features won't get
    native-mt
    support.
    :thread-please: 1
    c
    • 2
    • 12
  • a

    Arjan van Wieringen

    04/09/2022, 3:35 PM
    For the life of me I can't get 2 separate MPP modules working inside one project. I have 2 projects: • dom • mvu (which should refer to dom) I get errors ranging from "Projects must be configuring" to modules not loading tat all. Besides that, Gradle is complaining that I don't have configured any JS module, which I have.
    a
    • 2
    • 8
  • e

    Eric Ampire [MOD]

    04/09/2022, 7:38 PM
    Hey folks, what do you thing is a good option for iOS framework distribution when it came to create a KMM library ? • Apple XCFrameworks • CocoaPods • Apple Frameworks
    c
    l
    • 3
    • 3
  • h

    henrikhorbovyi

    04/10/2022, 3:17 PM
    Hello, everyone 👋. I’ve just created a new KMM project, but when tried to open it on XCode it shows the following error:
    The operation could''t be completed. Unable to locate a Java Runtime.
    Please visit <http://www.java.com> for information on installing Java.
    
    Command PhaseScriptExecution failed with a nonzero exit code
    From Android Studio I even can run it on an iOS emulator, but I can’t get preview or run it from xcode. Anyone to help me on that 😄 ?
    a
    j
    • 3
    • 7
  • f

    Francesco Bonnì

    04/11/2022, 12:58 PM
    Hello, everyone 🖖, We’ve just updated KMM project to have the same structure as the plugin created (before we did everything manually and was used as a library with publishing on Maven). We’re using kotlinx coroutines native-mt version with the strictly, iOS run smoothly, Android on build give this error:
    org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-native-mt.
    We tried to move the strictly on iOSMain and remove it from commonMain, Android run but iOS Crash for runBlocking{} no event loop. Does someone have an idea how to solve it🙏? Thank you
    p
    s
    • 3
    • 6
  • v

    Vivek Modi

    04/11/2022, 2:45 PM
    Hey Everyone ✌️. Can someone guide me what is d/w of this ktor library
    "io.ktor:ktor-client-core:2.0.0-beta-1"
    In android
    "io.ktor:ktor-client-android:2.0.0-beta-1"
    In Ios
    "io.ktor:ktor-client-ios:2.0.0-beta-1"
    Do we need to add core, android and ios library in the commonMain, androidMain and iosMain respectively?
    sourceSets {
        val commonMain by getting
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test"))
            }
        }
        val androidMain by getting
        val androidTest by getting
        val iosX64Main by getting
        val iosArm64Main by getting
        val iosSimulatorArm64Main by getting
        val iosMain by creating {
            dependsOn(commonMain)
            iosX64Main.dependsOn(this)
            iosArm64Main.dependsOn(this)
            iosSimulatorArm64Main.dependsOn(this)
        }
        val iosX64Test by getting
        val iosArm64Test by getting
        val iosSimulatorArm64Test by getting
        val iosTest by creating {
            dependsOn(commonTest)
            iosX64Test.dependsOn(this)
            iosArm64Test.dependsOn(this)
            iosSimulatorArm64Test.dependsOn(this)
        }
    }
    l
    • 2
    • 3
  • a

    Arjan van Wieringen

    04/11/2022, 6:11 PM
    I am getting some strange Gradle issues again:
    Caused by: org.gradle.api.GradleException: Cannot find dukat@0.5.8-rc.4 in yarn.lock
            at org.jetbrains.kotlin.gradle.targets.js.yarn.YarnEntryRegistry.find(YarnEntryRegistry.kt:37)
            at org.jetbrains.kotlin.gradle.targets.js.yarn.YarnBasics.yarnLockReadTransitiveDependencies$resolveRecursively(YarnBasics.kt:151)
    a
    • 2
    • 4
  • l

    Lucas Schiavini

    04/11/2022, 7:23 PM
    Did you guys ever set up a repository with a precompiled cocoapod library from the kotlin shared code? I know it could be done with Swift package manager, but I can't imagine programming without autocomplete on swift.
    k
    • 2
    • 2
  • l

    Lucas Schiavini

    04/12/2022, 2:07 PM
    Damn this kind of breaks both my legs
    :true-story: 3
    j
    r
    +2
    • 5
    • 18
  • t

    Thipok Cholsaipant

    04/13/2022, 7:01 AM
    I'm not sure if Scripting Host can be embedded for KMM targets other than JVM. Please let me know if any of you got a simple statement like "a == b" to evaluate in KMM projects! ❤️
    • 1
    • 1
  • s

    Slackbot

    04/13/2022, 9:09 AM
    This message was deleted.
    v
    c
    • 3
    • 5
  • r

    Robert Jaros

    04/13/2022, 1:19 PM
    In my KMP project, after upgrade to Kotlin 1.6.20, I see this error in IntelliJ only (no error when building from gradle). Is this correct behavior?
    ➕ 1
    a
    • 2
    • 7
  • v

    Vivek Modi

    04/13/2022, 3:06 PM
    Hey I am importing darwin in Kmm
    build.gradle.kts
    . I tried to import code in class but it giving error. Can someone guide me.
    k
    • 2
    • 9
  • d

    David Nedrow

    04/13/2022, 4:00 PM
    I don't have the
    jsmain
    or
    jstest
    directories, nor do I have anything configured for JavaScript in my Gradle files. Yet I see the below output when sync'ing the project. Any thoughts?
    g
    • 2
    • 3
  • h

    henrikhorbovyi

    04/13/2022, 6:16 PM
    Hey, everyone What should I “git ignore” in a kmm project? is there a .gitignore template for it?
    ➕ 1
    l
    m
    • 3
    • 7
  • j

    James Black

    04/13/2022, 7:02 PM
    In my shared subproject I have this enum. I would like to loop over it in Swift to have toggles.
    enum class ClothingTypes(val clothingLabel:String) {
        BLAZER("blazer"),
        BLOUSE("blouse"),
        UNDERSHIRT("undershirt");
    
        companion object {
            fun getNumberOfItems() = values().size
        }
    }
    This code isn't going to compile but basically how would I loop over ClothTypes and get each item in the enum? I did this on the Android side already. ClothingTypes.allCases.forEach { item in Toggle(isOn: $isPushEnable) { item.text } } This is basically what I want to do in a loop. Toggle(isOn: $isPushEnable) { Text(list.*get*(index: 0)!.clothingLabel) } Toggle(isOn: $isPushEnable) { Text(list.*get*(index: 1)!.clothingLabel) }
    • 1
    • 1
  • l

    Landry Norris

    04/13/2022, 7:27 PM
    Is there currently a workaround for having a jvm and android sourceset in the same kmm module right now? I'm getting the error that the java plugin is incompatible with the Android plugin. It looks like separate source sets aren't possible right now (I want to use expect/actual for several platforms).
    j
    • 2
    • 4
  • v

    Vivek Modi

    04/14/2022, 11:42 AM
    Hey guys. I want to find application version code in Kmm. In specific platform i.e. Android
    var versionCode = BuildConfig.VERSION_CODE
    it will return
    1.1
    iOS
    let appVersion = "iOS " + (Bundle.main.versionNumber ?? "")
    it will return
    1.1
    The above code is for native. What code should I use in KMM?
    h
    j
    • 3
    • 11
  • h

    hfhbd

    04/14/2022, 1:23 PM
    How do you sync a SwiftUI TextField with your Kotlin ViewModel using MutableStateFlow?
    n
    a
    • 3
    • 10
  • v

    Vivek Modi

    04/14/2022, 4:19 PM
    Hey guys, I need your advice or any sample project. I want to call session endpoint, in which I get accessToken. I want to use in accessToken in other endpoints as a authorisation. In android side we encrypt token and store in sharedpreference. Now I want to change in KMM to share with iOS team. So what is the best way in KMM?
    m
    • 2
    • 6
  • j

    James Ward

    04/14/2022, 7:40 PM
    In my sample multiplatform app I upgraded ktor to 2.0.0 and now I'm getting a build error:
    e: Could not find "io.ktor:ktor-utils-cinterop-utils" in [/home/jw/projects/kotlin-bars, /home/jw/.konan/klib, /home/jw/.konan/kotlin-native-prebuilt-linux-x86_64-1.6.10/klib/common, /home/jw/.konan/kotlin-native-prebuilt-linux-x86_64-1.6.10/klib/platform/linux_x64]
    Any ideas on what that means or how to resolve it?
    • 1
    • 1
  • t

    Tianyu Zhu

    04/14/2022, 9:45 PM
    Hi all! Is there a gradle plugin similar to
    java-test-fixtures
    but for kotlin multiplatform projects?
    j
    • 2
    • 2
Powered by Linen
Title
t

Tianyu Zhu

04/14/2022, 9:45 PM
Hi all! Is there a gradle plugin similar to
java-test-fixtures
but for kotlin multiplatform projects?
j

Javier

04/14/2022, 11:12 PM
there is a youtrack issue because Kotlin doesn't support it
t

Tianyu Zhu

04/15/2022, 2:34 PM
Oh do you happen to have the link?
View count: 20