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

    Chris Fillmore

    05/25/2022, 10:58 PM
    The KMM RSS Reader sample app isn't available on the iOS App Store in my country (Canada). Anyone happen to know why? Thanks!
    s
    m
    • 3
    • 4
  • j

    jared

    05/25/2022, 11:58 PM
    Will anyone please provide your suggestion on how to internally publish Kotlin multi-platform artifacts? This task has always been cumbersome in the past with outdated documentation. I am setting up a new org and would love for community input. I've used Artifactory in the past but only for JVM/Android artifacts. Please respond if you have suggestions. Ideally, an up-to-date guide on publishing for JS, native, and JVM/Android. Thanks.
    b
    l
    • 3
    • 8
  • j

    Jose Garcia

    05/26/2022, 8:07 AM
    Why can’t I find the following class in Kotlin/Native? I thought all of the Swift Foundation library was included with KMP; https://developer.apple.com/documentation/foundation/operationqueue
    a
    r
    • 3
    • 4
  • j

    Jose Garcia

    05/26/2022, 8:41 AM
    hi again, do you know if there is any way to get notified of Swift AppDelegate’s lifecycle methods (e.g. applicationDidEnterBackground) in Kotlin multiplatform?
    p
    • 2
    • 4
  • j

    Jack Darlington

    05/26/2022, 7:55 PM
    Hi all, I am having issues trying to assemble XCFramework. i am getting the following errors: -
    ld: warning: Could not find or use auto-linked library 'swiftCore'
    ld: warning: Could not find or use auto-linked library 'swiftQuartzCore'
    ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
    ld: warning: Could not find or use auto-linked library 'swift_Concurrency'
    ld: warning: Could not find or use auto-linked library 'swiftFoundation'
    ld: warning: Could not find or use auto-linked library 'swiftCompatibility51'
    ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
    ld: warning: Could not find or use auto-linked library 'swiftDispatch'
    ld: warning: Could not find or use auto-linked library 'swiftDarwin'
    ld: warning: Could not find or use auto-linked library 'swiftUIKit'
    ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
    ld: warning: Could not find or use auto-linked library 'swiftCompatibility50'
    ld: warning: Could not find or use auto-linked library 'swiftCoreImage'
    ld: warning: Could not find or use auto-linked library 'swiftCompatibilityDynamicReplacements'
    ld: warning: Could not find or use auto-linked library 'swiftMetal'
    ld: warning: Could not find or use auto-linked library 'swiftFileProvider'
    ld: warning: Could not find or use auto-linked library 'swiftDataDetection'
    ld: warning: Could not find or use auto-linked library 'swiftCompatibilityConcurrency'
    d
    • 2
    • 3
  • k

    kevin.cianfarini

    05/26/2022, 10:01 PM
    I'd like to re-raise
    Closeable
    as a feature Kotlin developers desire in the common stdlib. Here's an associated YouTrack Issue. This conversation has been brought up several times, and the argument against
    Closeable
    being defined in common was that the stdlib doesn't use it anywhere. Library maintainers have coped by creating their own implementations of
    Closeable
    and
    use
    . This is undesirable because: 1. Consumers of these libraries have to rectify multiple different namespaces of what is essentially the same interface. 2. Library maintainers need to recreate closeable for every one of their projects. Right now, Okio, SQLDelight, and Ktor all have their own implementations of
    Closeable
    . I'm sure there's many more libraries which do the same. I personally feel that coalescing around a single implementation of
    Closeable
    is import in the Kotlin ecosystem now that we've shown it to be a common use case in multiplatform code.
    👏 15
    👏🏼 1
    s
    • 2
    • 2
  • a

    Alex Logan

    05/27/2022, 8:59 AM
    Hey everyone! I wanted to ask what the general sentiment is around networking and KMM. I've found lots of people using KMM, but they keep their networking outside of the shared module. I've gone the other way, and I have the networking within the module, but its caused a lot of headaches, with every version of ktor having a new crash on iOS. Are others seeing this iOS instability, and other than pulling it out of shared, is there some way around it? There's various youtrack and github issues for every crash i've had, and more seem to spring up, but I don't see many people talk about these iOS problems 🤔
    w
    p
    +3
    • 6
    • 7
  • m

    Marek Niedbach

    05/27/2022, 12:56 PM
    Hi there! Is there any way to set the current/default locale when run
    gradle check
    ? I have some logic that rely on `Locale`/`NSLocale` and the unit tests are using the machine locale which may be out of control..
    ✅ 1
    j
    • 2
    • 7
  • l

    Landry Norris

    05/27/2022, 9:40 PM
    I am working on a kmm library that has UI elements at work. Right now, I’m using UIKit written in Kotlin for the UI on iOS, which allows me to have my logic and UI in the same codebase. I’m currently in the process of migrating the UI from the Android side to Compose, and was wondering if anyone’s used SwiftUI + KMM for a library. I know for a final app, it’s common to use SwiftUI in the app sources, but would this work just as well for a library, or are there any gotchas I may run into?
    k
    r
    • 3
    • 9
  • x

    xiaobailong24

    05/29/2022, 11:31 AM
    https://kotlinlang.org/docs/roadmap.html:rolling_on_the_floor_laughing::rolling_on_the_floor_laughing::rolling_on_the_floor_laughing: When will kotlin roadmap next update?
    👀 1
    p
    j
    • 3
    • 7
  • k

    Kwabena Berko

    05/30/2022, 11:17 AM
    Hello! 👋 Is there a way to write parameterised tests with kotlin.test ?
    👀 1
    j
    • 2
    • 2
  • d

    Dimitri Giani

    05/31/2022, 9:36 AM
    Hi all, I’ve a project with an old version of KM, how can I update the project to the new version?
    s
    • 2
    • 3
  • r

    Ronny Remesnik

    05/31/2022, 1:19 PM
    Hey all, I have android project that is using KMP project. KMP have modules and when I’m trying to import code of KMP modules to android project, the AS mark it with RED and say when I click “Can’t find declaration” When the imported code is not from module, but from the
    commonMain
    folder on the root, all imported well. But all code compiles well, no problem on compilation, only visual… problem started since upgrading Kotlin to 1.6.21 Thanks in advance…
    m
    • 2
    • 2
  • m

    martmists

    05/31/2022, 2:59 PM
    Are there multiplatform alternatives to classes like Optional and StackOverflowError?
    j
    m
    • 3
    • 16
  • a

    Ali Khaleqi Yekta

    05/31/2022, 3:24 PM
    Is there a way to set the bytecode version to 17 for the JVM, and to 1.8 for Android (for the common/shared module)? I tried setting:
    ...
    kotlin {
        android {
            compilations.all { kotlinOptions.jvmTarget = "1.8" }
        }
        jvm {
            compilations.all { kotlinOptions.jvmTarget = "17" }
        }
        ...
    }
    ...
    inside the
    build.gradle.kts
    of my common module, but when building the project, it fails with:
    ... error: cannot inline bytecode built with JVM target 17 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option ...
    r
    m
    +2
    • 5
    • 12
  • s

    Sam

    05/31/2022, 7:44 PM
    Hi all, just started using multiplatform and I'm loving it. Most things (with the exception of the crap that is objective C generics 😆 ) just works out of the box. I have a feeling the fact KMM is still in alpha though will mean I have a hard time convincing others that it's production ready. Does anyone have any idea when it will move to beta? I know online it says
    Beta is expected in spring 2022
    Anyone got any more detail?
    m
    l
    • 3
    • 8
  • s

    Sam

    05/31/2022, 8:18 PM
    Another question! I realise this isn't strictly a Kotlin question but has anyone managed to get SonarCloud/SonarQube setup for a KMM project? Specifically around the combined code coverage metrics for the Swift and Kotin code? Just asking before I start deep diving into it incase someone's already solved some of these problems
    l
    • 2
    • 2
  • r

    Ran

    06/01/2022, 6:14 AM
    KMM compiles the code to bytecode for Android and native for iOS, and the KMM declares that there is not much performance loss. But In my situation, the performance is not on the same level compared to the native platform. I wrote a multiplatform calculation library using kotlin. The library contains high precision calculations and the kotlin standard library doesn't have corresponding tools. So, I use platform-APIs to achieve that. In js, I use bignumber.js; In iOS I use NSDecimalNumner in Foundation. But after a performance test on JS and iOS platforms, the former has 4 to 6 times lower performance, the latter has 7 to 8 times lower performance. Is there anyone who can tell me why is the performance degraded so much and how can I solve it?
    a
    k
    a
    • 4
    • 19
  • m

    ManApart

    06/01/2022, 11:49 AM
    ---------------------------- EDIT: resolved. Another issue I'm having is running the unit tests through the ide compilation instead of gradle compilation. Aka a run config using gradle and
    :cleanJvmTest :jvmTest
    passes the tests, but doing a junit 'all in package' (or running the jvm main file/entry point) test fails with an error that seems to indicate that the expect / actual classes aren't being correctly understood. I get a bunch of errors like the one below, despite the IDE finding the corresponding declarations / gradle-run tests passing.
    \src\jvmMain\kotlin\core\history\SessionHistory.kt:9:15
    Kotlin: Actual object 'SessionHistory' has no corresponding expected declaration
    I'm wondering if I need to modify the run configuration somehow to understand the module structure? I've done a hello world project with the same setup of having a jvm main call code in common that has expect/actual and it worked as I expected. So I assume I've done something wrong with this more complicated setup. I realize this is a more vague ask but would appreciate any pointers of things to track down. Thanks!
    • 1
    • 5
  • m

    Matt Nelson

    06/01/2022, 2:25 PM
    Wen apple targets available on Linux?
    l
    j
    +2
    • 5
    • 19
  • m

    Marco Righini

    06/01/2022, 6:40 PM
    Hello everybody, we are quite interested in how companies are managing building, distributing and consuming the KMM libraries in the android and ios projects. The case is the following: - android, ios and kmm in different repositories - work on kmm and android/ios at the same time, i.e. we want to check how kmm changes are working in android/ios before merging the kmm changes - be able to assess point above both in ci and locally Our current situation is the following: - kmm is a submodule in android and we are using composite builds. Problem: imports are shown in red but compilation is working ok (composite builds are not supported in kmm yet). This is a really good solution, submodule handling need learning but the gain is high, btw red imports are a blocker - kmm is a submodule in ios and it is built when building the ios app as standalone project (kmm is built first and xcframework is copied in the ios project). Problems: long build times, random compilation problem in xcode (due to xcode caching issue) We are thinking about: - android: prebuild and distribute kmm. This is ok when not working on kmm changes but what's the best way to work locally? Should we use a gradle flag for switching between the two modes (prebuild or build locally)? We'll anyway the composite build red import problem when working locally so we'll need to remove composite build, but it will remove the possibility to seamless navigate between android and kmm code in the ide. Also, in CI Android PRs will depend on prebuild KMM PR binary, how to deal with this dependency? - ios: prebuild and distribute xcframework. Here we have similar issues of the point above related to android
    l
    • 2
    • 2
  • r

    Rachel Carandang

    06/01/2022, 6:48 PM
    I’m getting an error when building for the iOS simulator on Mac M1 (detailed logs attached in the thread). Originally the iOS build of my shared library is complained target ios_simulator_arm64 is missing. When I added
    iosSimulatorArm64()
    as a target to my build.gradle.kts, then the build complains that my “expect” classes are missing for that target with:
    Expected class 'SettingsStorage' has no actual declaration in module <shared> for Native.
    What is the proper way to get around this error and build for the simulator?
    l
    • 2
    • 5
  • m

    Marko Novakovic

    06/01/2022, 9:03 PM
    I started getting
    Class … is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler
    for classes and top level functions in
    shared
    module. Am using Kotlin version
    1.6.21
    for month now and today I started to get those errors. I don’t understand this
    e
    k
    • 3
    • 5
  • r

    Rachel Carandang

    06/01/2022, 10:33 PM
    I am getting a new error on my M1 when trying to run my shared library on iOS Simulator Arm64 (not an issue when running on a physical device). The command CompileSwift fails with:
    <unknown>:0: error: unable to load standard library for target 'arm64-apple-ios10.0'
    I’ve tried everything suggested online, clean derived data, restart xcode, clear environment, download ios 10 simulators (there are none). I strongly suspect it’s related to errors I had earlier compiling the shared KMM framework: https://kotlinlang.slack.com/archives/C3PQML5NU/p1654109309669219 Does anyone know why this might be happening? Its pretty ambiguous and nothing online has helped so far. This seems to be a problem with the simulator target only.
    l
    • 2
    • 5
  • r

    ribesg

    06/02/2022, 2:23 PM
    Anyone knows what usually causes this issue?
    No matching variant of <myKmpLib> was found. 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'
    While trying to build a
    shared
    module of a KMM app having a dependency on a KMP library defined in its
    commonMain
    sourceSet
    l
    m
    • 3
    • 35
  • j

    jean

    06/02/2022, 3:04 PM
    I can’t resolve this two imports
    import kotlinx.coroutines.newSingleThreadContext
    and
    import kotlinx.coroutines.runBlocking
    even though I added the
    native-mt
    version of coroutines. Am I missing something?
    val commonMain by getting {
        dependencies {
            implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1-native-mt")
        }
    }
    val commonTest by getting {
        dependencies {
            implementation(kotlin("test"))
            implementation(kotlin("test-common"))
            implementation(kotlin("test-annotations-common"))
            implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1-native-mt")
        }
    }
    g
    • 2
    • 4
  • c

    Claude Brisson

    06/02/2022, 3:54 PM
    (crossposting from #intellij where I didn't get an answer...) I have a multimodule gradle project, and among the modules I have: + a multiplatform application module, MAPP, with common/jvm/js targets + a java library module, JLIB MAPP is supposed to depend on JLIB, but whenever I add the JLIB dependency to the MAPP build script, the MAPP source roots get broken at sync time, as if IntellijIdea was trying to find standard [main] and [test] source roots instead of multiplatform ones. If I comment the dependency to JLIB, after deleting the
    .idea
    folder, the sync succeeds and everything goes back to normal, with source and test roots properly detected in commonMain, jvmMain, jsMain and the same for test. Somehow, IntellijIdea mixes gradle build models between multiplatform and java plugins from different modules, and I don't have any clue why it happens. Versions: + IntelliJ IDEA 2021.3.3 (Ultimate Edition) Build #IU-213.7172.25, built on March 15, 2022 + Kotlin plugin 213-1.6.21-release-334-IJ6777.52 + gradle 7.1 or 7.4.2
    • 1
    • 1
  • n

    Nacho Ruiz Martin

    06/02/2022, 4:24 PM
    Hello! 👋 I was wondering... Given that the recommended approach is to have a multiplatform project with different targets in the same repo, how do you approach the release cycle? I clearly want them to be independent, but what strategy would be a good one in terms of git branch management? I normally fire the CI workflow to build and push the artifact in the case of a tag creation on the master branch, but what if there could be three or more different targets and only one of them should be released? Thanks! 🙇
    b
    • 2
    • 4
  • a

    Ali Khaleqi Yekta

    06/02/2022, 6:35 PM
    Why is androidMain different and how to fix this? I'm using the latest stable Android Studio and kotlin 1.6.21. I have a problem that I thought might be related to this. There's an actual class inside androidMain that doesn't recognize a dependency that its expect class inside commonMain also implements with no problems.
    l
    n
    • 3
    • 3
  • m

    martmists

    06/02/2022, 7:51 PM
    Is there a way to combine kotlin multiplatform and kotlin multiplatform mobile to use compose to create an app for all desktop and mobile platforms?
    l
    • 2
    • 2
Powered by Linen
Title
m

martmists

06/02/2022, 7:51 PM
Is there a way to combine kotlin multiplatform and kotlin multiplatform mobile to use compose to create an app for all desktop and mobile platforms?
l

Landry Norris

06/02/2022, 7:57 PM
You should be able to use compose in a source set shared by android, jvm, and iOS right now. I’ve only tested it with android and iOS, but it seems to work fine.
Note that if you include iOS, #compose-ios only supports parts of compose. To see what is supported, look here. Anything that isn’t set to ComposePlatforms.JVM_BASED is usable in iOS.
👀 2
View count: 19