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

    Justin Brooks

    12/21/2022, 1:19 AM
    I'm working on a presentation around Kotlin Multiplatform. I've got a simple KMM app working, but to make the demonstration more compelling as an alternative to our code sharing strategies, I'm also trying to build the common (multiplatform) library with an npm library artifact that I can consume in a NextJS app. However, I've not figured out a way to get the package version to appear in the generated package.json—which makes consuming it as an npm package problematic.
    Knapsack# cat build/js/package.json
    {
      "name": "Knapsack",
      "version": "unspecified",
      "private": true,
      "workspaces": [
        "packages/Knapsack-common",
    I've tried to configure it a few different ways, but the current code https://github.com/jzbrooks/Knapsack/blob/1a720273a148cade22d068108528ccbe5906ce2a/common/build.gradle.kts#L13. I searched the issue tracker since but didn't find anything relevant. Does anyone know what I'm missing?
    • 1
    • 1
  • s

    Sunny

    12/21/2022, 9:51 AM
    Hi, I am running into
    error: use of '@import' when modules are disabled
    Trying to integrate an analytics library Snowplow. added the relevant pod
    cocoapods {
            pod("SnowplowTracker")
        }
    Log Task :cinteropSnowplowTrackerIosArm64
    Exception in thread "main" java.lang.Error: ../build/cocoapods/synthetic/IOS/build/Release-iphoneos/SnowplowTracker/SnowplowTracker.framework/Headers/SPSnowplow.h:31:1: error: use of '@import' when modules are disabled
    at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:274)
            at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1196)
            at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:1185)
            at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:1181)
            at org.jetbrains.kotlin.native.interop.gen.jvm.DefaultPlugin.buildNativeIndex(Plugins.kt:33)
            at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:289)
            at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLibSafe(main.kt:214)
            at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:80)
            at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
            at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:40)
            at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:62)
    Any workarounds for this?
    • 1
    • 1
  • l

    Luong Vo

    12/21/2022, 11:23 AM
    We (developers at Nimble) just built a KMM library https://github.com/nimblehq/jsonapi-kotlin that supports decoding JSON:API string response. I saw many ppl ask about it (and me too) so feel free to use it. Please don’t forget to give us a star 🌟 It’s being published via GitHub Packages so please check the installation section.
    @Serializable
    data class ExampleModel(val title: String)
    
    val body = """
    {
      "data": {
        "type": "articles",
        "id": "1",
        "attributes": {
          "title": "JSON:API paints my bikeshed!"
        }
      }
    }
    """
    
    val json = Json {
        prettyPrint = true
        isLenient = true
        ignoreUnknownKeys = true
    }
    val data = JsonApi(json).decodeFromJsonApiString<ExampleModel>(body)
  • d

    dimsuz

    12/21/2022, 12:43 PM
    Hi! Created a new project with 2 gradle modules, both KMM (1.7.20) and when I add dependency I see this warning. Everything compiles fine, but I'd still like to resolve this warning somehow:
    k
    • 2
    • 2
  • c

    Ciaran Sloan

    12/21/2022, 7:59 PM
    I'm working on a KMM library, using cinterop and having some issues when I export my library to a framework 🧵
    l
    r
    • 3
    • 17
  • c

    Conrad Kramer

    12/21/2022, 10:16 PM
    Has anyone seen issues with unit testing and codesigning? I am seeing this error when running unit tests on my M1 Mac running macOS 13.1:
    > Task :Shared:macosArm64Test FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':Shared:macosArm64Test'.
    > command '/Users/conradev/Projects/Wallet/Shared/build/bin/macosArm64/debugTest/test.kexe' exited with errors (exit code: 137)
    and the corresponding log in the system log is generated:
    default	14:14:45.212066-0800	kernel	ASP: Security policy would not allow process: 43402, /Users/conradev/Projects/Wallet/Shared/build/bin/macosArm64/debugTest/test.kexe
    • 1
    • 1
  • m

    martmists

    12/22/2022, 1:10 AM
    How would I set up Gradle to build a multiplatform native library? (i.e. wasm for JS, native with JNI for Android + desktop, etc)
  • x

    xxfast

    12/22/2022, 1:57 AM
    Hi all. I'm running into issues when exporting my sealed types across multiple modules. For example, my module setup is
    :app
    ⎿:feature-1
    ⎿:feature-2
    :app
    is the only module I'm depending on from iOS, but I am exporting my feature modules. I can export sealed types from
    :app
    just fine
    sealed class AppSealedType {
      object AppTypeA: AppSealedType()
      object AppTypeB: AppSealedType()
    }
    And they do show up on the swift side. However, when I define a seal type on one of the
    :feature-x
    modules
    sealed class FeatureSealedType {
      object FeatureTypeA: AppSealedType()
      object FeatureTypeB: AppSealedType()
    }
    Only the top seal interface is exported. I can trick the tooling to "force" export the sealed child types by referencing them in the
    iosMain
    of the
    :app
    as a workaround
    val FeatureTypeA = FeatureSealedType.FeatureTypeA
    When I do that, the child types are exported Is this a known bug/limitation? Is there a way export all child types of my sealed types? More details in the 🧵
    v
    c
    a
    • 4
    • 6
  • s

    Shubham Singh

    12/23/2022, 6:05 AM
    Hi Folks! Is there a way to tell a KMP project to NOT fetch a common dependency for 1 particular platform For example, this dependency:
    implementation("dev.icerock.moko:kswift-runtime:0.6.1")
    is only available for KMM but my project supports Android, iOS, and Web as well. So can I instruct KMP to not fetch its deps for JS?
    x
    j
    +2
    • 5
    • 8
  • m

    ManApart

    12/23/2022, 8:43 PM
    Cross posting for visibility. If anyone could point me in the right direction, I'd really appreciate it. https://kotlinlang.slack.com/archives/C19FD9681/p1671824807177329
  • e

    Eugene Maksymenko

    12/24/2022, 1:11 AM
    WorldWindKotlin - the first Kotlin multi-platform 3D GIS update 1.1.5 released https://github.com/WorldWindEarth/WorldWindKotlin/releases/tag/v1.1.5
    t
    • 2
    • 1
  • h

    humblehacker

    12/24/2022, 8:49 PM
    Is it possible to develop a KMM library and app in tandem? I mean is there a workflow where I can make changes to the library, make corresponding changes to the app, and build & run to test? Or must I first publish my library changes (to MavenLocal for example), update dependencies in my app, make my app changes, and only then can I build and test?
    d
    b
    • 3
    • 7
  • k

    Kirill Zhukov

    12/25/2022, 3:49 AM
    Is there a reason why
    jvmMain
    source set access is not provided by Kotlin DSL (unsure how this works…)? For example, following:
    kotlin {
      android()
      jvm()
    
      sourceSets {
        val commonMain by getting {
          // ...
        }
        
        val androidMain by getting {
          // ...
        }
        
        val jvmMain by getting {
          // ...
        }
      }
    }
    Can be replaced with this, except for
    jvmMain
    :
    kotlin {
      android()
      jvm()
    
      sourceSets {
        commonMain {
          // ...
        }
    
        androidMain {
          // ...
        }
    
        // `jvmMain` extension is not provided
        val jvmMain by getting {
          // ...
        }
      }
    }
    m
    • 2
    • 1
  • s

    spierce7

    12/25/2022, 4:07 AM
    Has anyone tried out korge? Do you have any thoughts on how complete / ready for production it is?
    l
    • 2
    • 1
  • i

    Idan

    12/25/2022, 1:31 PM
    Hello and Marry Christmas 🎄 I have an issue where adding a kmm module (i.e domain) module to shared module results with Prefix added to the generated iOS classes, for example User class under domain will be DomainUser in iOS How can I remove this prefix in build.gradle Thanks
    j
    • 2
    • 3
  • s

    Shubham Singh

    12/25/2022, 2:41 PM
    Hi folks Merry Christmas 🎄 I've been facing this same error: https://stackoverflow.com/questions/70632359/using-kmm-shared-library-for-use-in-xcode-gives-several-warnings-and-errors-when Unfortunately, there are no responses on this SOF post. Could we please have a look at it?
  • s

    spierce7

    12/26/2022, 4:40 AM
    Has anyone tried https://github.com/korlibs/kproject before? It basically seems like carthage for kotlin. If it actually does what it sounds like... being able to publish libraries while not having to mess with maven central... that'd be amazing...
  • v

    Vitaliy Zarubin

    12/26/2022, 8:50 AM
    It works )
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
        if value == range {
            onValueChangeFinished(value.map { Double($0) })
        }
    }
    c
    • 2
    • 1
  • e

    Elio Maroun

    12/27/2022, 8:59 AM
    can I use ktor logger in shared module in kmm ?
    c
    s
    • 3
    • 2
  • k

    Kirill Zhukov

    12/27/2022, 9:53 PM
    android()
    configures
    androidMain
    that depends on
    commonMain
    already, you can probably drop 29-31 configuration.
    n
    t
    • 3
    • 2
  • c

    Christian Würthenr

    12/29/2022, 10:50 AM
    I'm trying out Android Studio 2022.1.1 RC3 and it seems like the KMM plugin isn't able to start iOS tests from within the IDE. I only get this in the logs:
    FAILURE: Build failed with an exception.
    * What went wrong:
    Execution failed for task ':shared-br-network:iosSimulatorArm64Test'.
    > No value present
    If I open the project in 2021.3 everything works as expected, also when I use
    ./gradlew :shared-network:iosSimulatorArm64Test
  • e

    Elio Maroun

    12/29/2022, 1:47 PM
    https://stackoverflow.com/questions/74951871/i-have-nested-scopes-but-injection-is-not-working
    c
    • 2
    • 1
  • m

    Mendess

    12/29/2022, 2:17 PM
    I wrote a test in commonMain, it uses
    = runTest
    and internally it uses
    GlobalScope.launch
    but this call is blocking forever and the callback I'm passing to it doesn't ever run, how can I debug this?
    c
    • 2
    • 3
  • t

    tylerwilson

    12/29/2022, 4:22 PM
    Updating MPP module to Kotlin 1.8.0, trying to get rid of this new warning:
    Multiplatform/Android-V1-SourceSetLayout: Multiplatform/Android-V1-SourceSetLayout is deprecated...
    I add it then I get new warnings:
    Multiplatform/Android-V2-SourceSetLayout: Usage of 'Android Style' source directory
    are there any docs on this new V2 layout. Migration guide perhaps?
    a
    • 2
    • 4
  • t

    tylerwilson

    12/29/2022, 5:08 PM
    And thank you so much for fixing this issue: https://youtrack.jetbrains.com/issue/KT-47355 My gradle file is sooo much cleaner without the workaround in there...
  • p

    Parvez Qureshi

    12/30/2022, 3:00 AM
    In Kotlin Multiplatform for Mobile, how we can write unit test to check intermediate values of
    KLiveData
    , can anyone give an example ?
    z
    a
    • 3
    • 3
  • s

    Shubhasai Mohapatra

    12/30/2022, 5:30 AM
    is there any way so that we can add dependencies like for firebase in shared dependency and write code for multiple platform in single go
    m
    • 2
    • 2
  • h

    Hakan

    12/30/2022, 7:00 AM
    Hi everyone 👋 I am trying to add
    DataDog
    library in iosMain part of the KMM project. But Somehow I can not import the library into Kotlin file. Here is the ticket that I opened yesterday. https://youtrack.jetbrains.com/issue/KT-55687/Can-not-add-DataDog-Dependency-via-CocoaPods-in-Kotlin-Multiplatform-Mobile-Project I really appreciate if you guide me. Thanks.
    k
    d
    m
    • 4
    • 14
  • a

    andylamax

    12/30/2022, 7:04 AM
    x-posting here coz it is also relevant https://kotlinlang.slack.com/archives/C0B8H786P/p1672383513031109
  • e

    Elio Maroun

    12/30/2022, 10:08 AM
    https://stackoverflow.com/questions/74951871/koin-android-kmm-i-have-nested-scopes-but-injection-is-not-working
Powered by Linen
Title
e

Elio Maroun

12/30/2022, 10:08 AM
https://stackoverflow.com/questions/74951871/koin-android-kmm-i-have-nested-scopes-but-injection-is-not-working
View count: 34