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

    robstoll

    12/28/2020, 10:48 PM
    updating to the new MPP plugin/Kotlin 1.4.21 is such a pain point, I really hoped it would be smoother 😞 I hope someone can answer me the following questions 1. ✔️ Is it considered normal that a
    gr build
    which fails due to failing test succeeds when I re-run it (without changing anything) -> jvmTest is skipped
    as it is up-to-date
    (allTest is executed but does nothing besides generating a html report). How can I change this behaviour? => seems like it: https://blog.gradle.org/stop-rerunning-tests 2. ✔️How can I disable the
    Please initialize at least one Kotlin target in...
    check? It was not there in 1.3.72 but is in 1.4.21. I have a root project which does not contain any source but several MPP sub-projects 3. ✔️ After the update to 1.4.21 I cannot longer run tests (via gradle), I get
    The root cause java.lang.UnsupportedOperationException was thrown at: org.jetbrains.kotlin.load.kotlin.TypeSignatureMappingKt.mapType(typeSignatureMapping.kt:99)
    during
    compileTestKotlinJvm
    is this a known problem? 4. ✔️ not really a problem as there is an easy workaround but out of curiosity why do
    js
    targets need the extra definition of the dependency to kotlin-stdlib-js?
    👀 1
    i
    • 2
    • 8
  • q

    Qracle

    12/29/2020, 1:01 AM
    General question about project structure for KMM, does it make any difference (like build time, or restriction in expanding to web in the future) if you have a top-level KMM module which includes all the other modules as a dependency versus multiple KMM modules (as separate features) at the top level ? Root • android-app • ios-app • shared -user -products -routines -entries
    j
    m
    • 3
    • 10
  • j

    Joaquim Ley

    12/29/2020, 4:33 PM
    Anyone has exp dealing with Kotlin sealed classes + Generics working in Swift? I’m struggling a bit to find a good implementation e.g
    sealed class Result<T> {
      Success(val data: T): Result()
      Error(val message: T): Result()
    }
    How would you switch case with a swift optional + handle both success and error cases?
    j
    s
    • 3
    • 7
  • a

    andylamax

    12/30/2020, 4:08 AM
    Hello kotliners, A question of opinion here. I have been building multiplatform libs to be shared across (jvm,android and js). In very many cases, my source codes only reside in
    commonMain
    which is obviously a good thing. However, I do end up including
    jvm
    ,
    android
    and
    js
    as compilation targets. My question. Since the
    android
    platform basically uses
    java
    classes. Is there a need for me to keep including
    android
    as a compilation target? coz I do have the java target and all. Those who skipped compiling for the
    android
    target, have you ever faced an issue during importing your library to an
    android
    development? Note: All targets are compiled using the
    IR
    backend
    t
    p
    • 3
    • 4
  • m

    Michal Klimczak

    12/30/2020, 8:44 AM
    Has anyone tackled the code generation for boilerplate between coroutines and Swift code? My plan is to use something similar to this https://dev.to/touchlab/working-with-kotlin-coroutines-and-rxswift-24fa to use coroutines/Flow as Swift Combine Publishers on the Swift side. But it requires a lot of boilerplate for a big project. Maybe there's a better alternative? I wanted to write a generic wrapper for the default completion blocks generated for
    suspend
    functions, but they don't have a stable signature, so I don't think it's possible.
    j
    • 2
    • 7
  • w

    wuseal

    12/31/2020, 10:53 AM
    Hi, can anybody tell me how to use [AtomicInt](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.native.concurrent/-atomic-int/) in common code?
    m
    t
    a
    • 4
    • 4
  • a

    Animesh Sahu

    12/31/2020, 11:04 AM
    How to test kotlin jvm? I can test Kotlin/Native very easily... But for K/JVM I get this ^
    c
    • 2
    • 14
  • j

    Jolas

    12/31/2020, 1:15 PM
    I’m trying to build KMP project on a windows machine and getting this error
    C:\Users\vtouch\.konan\dependencies\msys2-mingw-w64-x86_64-clang-llvm-lld-compiler_rt-8.0.1/bin/clang++ command returned non-zero exit code: 1.
    output:
    C:\Users\vtouch\.konan\dependencies\msys2-mingw-w64-x86_64-clang-llvm-lld-compiler_rt-8.0.1\bin\ld: cannot find -lsqlite3
    C:\Users\vtouch\.konan\dependencies\msys2-mingw-w64-x86_64-clang-llvm-lld-compiler_rt-8.0.1\bin\ld: cannot find -lcurl
    Can someone please help resolving this issue. I am nee to windows dev environment.
    a
    • 2
    • 8
  • j

    Joaquim Ley

    12/31/2020, 1:22 PM
    Is there an easy way in Swift to await an async operation? So instead of relying in callback fashion we would suspend
    // This isLoggedInUseCase is a Kotlin suspend fun
    isLoggedInUseCase.invoke { task, error in
        switch task {
        case let task as TaskResultSuccess<KotlinBoolean>:
            // Callback style result here with true|false
            break;
        case _ as TaskResultError<KotlinBoolean>:
            // Handle error
            break;
        default: break;
        }
    }
    
    // What I wanted is to await the result of the usecase exec and
    // Only then continue execution of the 'main' func
    j
    r
    • 3
    • 29
  • j

    Jeff Lockhart

    12/31/2020, 10:18 PM
    I'm trying to setup a KMM module with Couchbase Lite as a platform dependency for both Android and iOS. I'm running into errors getting this to work with CocoaPods for iOS:
    Exception in thread "main" java.lang.IllegalArgumentException: 'CBLQueryMeta' is going to be declared twice
    	at org.jetbrains.kotlin.native.interop.gen.KotlinFile.<init>(KotlinCodeModel.kt:257)
    	at org.jetbrains.kotlin.native.interop.gen.StubIrBridgeBuilder$kotlinFile$1.<init>(StubIrBridgeBuilder.kt:44)
    	at org.jetbrains.kotlin.native.interop.gen.StubIrBridgeBuilder.<init>(StubIrBridgeBuilder.kt:46)
    	at org.jetbrains.kotlin.native.interop.gen.StubIrDriver.run(StubIrDriver.kt:122)
    	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:315)
    	at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:73)
    	at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
    	at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
    	at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:41)
    build.gradle.kts:
    plugins {
        kotlin("multiplatform") version "1.4.21"
        kotlin("native.cocoapods") version "1.4.21"
        id("com.android.library")
    }
    ...
    
    kotlin {
        android()
        ios()
        cocoapods {
            summary = "TBD"
            homepage = "TBD"
            ios.deploymentTarget = "9.0"
            pod("CouchbaseLite") {
                version = "~> 2.8.1"
            }
        }
        ...
    }
    ...
    Any tips on getting this to work?
    • 1
    • 1
  • b

    birdsofparadise

    01/02/2021, 11:18 PM
    Anyone using MP, Android Compose, and running into an issues with the
    remember
    API in your "shared" module?
    t
    • 2
    • 2
  • d

    dasralph

    01/03/2021, 11:28 AM
    I want to use Kotlin JS to create a JavaScript library with TypeScript declaration files (*.d.ts). For this, I use the new IR compiler. But I’m wondering which Gradle task I should use for it. Currently, I’m using
    ./gradlew clean compileProductionExecutableKotlinJs
    . But
    compileProductionExecutableKotlinJs
    does not appear in the
    ./gradlew tasks
    list, so I assume it is not the right one. Which Gradle task should I use?
    a
    • 2
    • 1
  • d

    dasralph

    01/03/2021, 11:40 AM
    When I try to compile a data class with default values with the IR compiler to JavaScript, I get this error:
    IllegalStateException: Can't find name for declaration FUN name:Foo_init_$Create$ visibility:public modality:FINAL <> (bar:kotlin.String?, $mask0:<http://kotlin.Int|kotlin.Int>, $marker:kotlin.js.DefaultConstructorMarker?) returnType:api.model.Foo
    . I assume this is a bug but is there a small workaround for it? Or do I need to wait until it is fixed?
    @ExperimentalJsExport
    @JsExport
    data class Foo(
        val bar: String? = null
    )
    a
    • 2
    • 1
  • a

    Animesh Sahu

    01/05/2021, 5:08 AM
    How to see stdout n stderr of failing tests, this setting only applies for jvm:
    tasks.withType<Test> {
    	testLogging {
    		exceptionFormat = TestExceptionFormat.FULL
    		showStandardStreams = true
    		showStackTraces = true
    	}
    }
    ➕ 1
    u
    • 2
    • 2
  • a

    Alex

    01/05/2021, 9:10 AM
    Regarding of testing, I’ve been writing some tests on commonMain and they’re always running under ios or iosX64 Gradle tasks. I’ve downloaded the kmm-sample project from KMM documentation and the same happens there. Does anybody knows why the shared code is always executed under ios tasks? I’m having difficulties to find some quality content about shared tests.
    t
    r
    • 3
    • 5
  • d

    Dragos Rachieru

    01/05/2021, 11:12 AM
    Hello, I am having a hard time publishing my multiplatform library to Sonatype. My build.gradle file is this: https://github.com/dragossusi/sevens-payload/blob/master/payload/build.gradle.kts I somehow made it work, but it creates 2 repositories at the same time, 1 fails everytime.
    g
    a
    j
    • 4
    • 9
  • i

    Ivy

    01/05/2021, 12:42 PM
    Hello, I just started the KMM project. 😁 Before that, I mainly developed Android. So I wonder what IDE you use when writing Swift code in the KMM project. It’s very uncomfortable to write Swift code in Android Studio, so I’m using XCode and Android Studio alternately. Are there any tips for me?
    m
    y
    • 3
    • 5
  • h

    Himanshu Singh

    01/05/2021, 1:16 PM
    Hello All, is there any project which is open source and live in App/Play store ? Wanted to check out the app
    y
    m
    • 3
    • 5
  • m

    Md Hanif

    01/05/2021, 6:19 PM
    Hi. is DataStore available for KMM ? like I have used this library which uses shared pref and NSUSerDefaults for their native storage am not sure if we can do something like this using datastore ? Would I require to create my own native preference storage file which uses datastore and NSUserdefaults to store preference or is there any built in or third party available ?
    m
    r
    • 3
    • 7
  • j

    jean

    01/06/2021, 9:32 AM
    I used to have a
    jvm
    target for which the generated library was in kotlin and readable from my android app. Since a changed the target to
    android
    both the debug and release libraries are in Java and not readable from android studio (it gives me the option to “Decompile to Java” which gives unclear/non-readable code, “Download sources” which does nothing and “Choose sources” for which I don’t know what to select. Isn’t there a simple config for the debug variant at least to make it readable just as the file from the shared library?
    • 1
    • 1
  • j

    Javier

    01/06/2021, 12:25 PM
    gradlew allTests
    is not running
    allTests
    for
    androidTest
    source set, so I have to use
    gradlew test
    , is there a way to force
    allTests
    to detect the android tests? I could do something like allTests dependsOn test but should be great
    allTest
    just works by default with them
    • 1
    • 1
  • j

    Jiri Bruchanov

    01/06/2021, 2:11 PM
    Hi, anyone who could help with a kmm project setup ?
    m
    • 2
    • 5
  • p

    Paulo Pinheiro

    01/06/2021, 5:12 PM
    What is the proper way on multiplatform to add an external java sourceset?
    c
    • 2
    • 1
  • m

    max.cruz

    01/07/2021, 12:10 PM
    Hi. Someone has experience working with KMM on the m1/apple silicon/arm macbooks? I can configure the shared module to run on iOS physical devices but it’s broken for simulators
    Building for iOS Simulator, but linking in dylib built for iOS, file '/Users/.../Shared.framework/Shared' for architecture arm64
    ➕ 1
    s
    m
    s
    • 4
    • 14
  • j

    Jean Carlos

    01/07/2021, 1:38 PM
    Hello! Someone has an example of a multi-module based KMM? I have seperated the domain and I want to share it embedded into shared module
    d
    j
    • 3
    • 11
  • a

    Amritansh

    01/07/2021, 8:11 PM
    I am getting unresolved reference due to sqldelight when I run
    ./gradlew build
    Unresolved reference: UIKit
    Unresolved reference: UIDevice
    Unresolved reference: db
    Unresolved reference: squareup
    Unresolved reference: SqlDriver
    Unresolved reference: NativeSqliteDriver
    Unresolved reference: AppDatabase
    It works fine when I run the app. KotlinVerion = 1.4.2 sqldelight version =1.4.4
    m
    • 2
    • 2
  • d

    dirk.dittert

    01/08/2021, 1:19 PM
    Has anyone experience with building and integrating KMM code into an iOS application? I have prototyped the complete workflow for an Android and iOS app. One thing that I could not get to work on iOS was debugging. The debugger in Xcode basically only shows the address of the object but no members. Is there a way to improve that behavior?
    j
    • 2
    • 4
  • m

    Marcus

    01/08/2021, 1:42 PM
    Hi everyone! Is there some up-to-date guide on how to use a Cocoapod in the iOS part of a shared module? Following this isn't even quite possible since apparently the syntax for pod() changed since it's creation. And if I extrapolate the instructions and simply add
    pod("AFNetworking")
    to the cocoapods section in build.gradle.kts, I get
    > Task :shared:cinteropAFNetworkingIosArm64 FAILED
    Exception in thread "main" java.lang.Error: /var/folders/4g/3s9scp9d5593dphx7n_7nhk40000gn/T/tmp1272859169392324213.m:1:9: fatal error: module 'AFNetworking' not found
    I'm trying this in an KMMApplication template from AndroidStudio 4.1.1 running Kotlin Plugin 1.4.21-release-Studio4.1.1, in which I've only modified build.gradle.kts to add
    kotlin("native.cocoapods")
    to the plugins, changed the
    ios {
    …
    }
    block to
    ios()
    to get rid of the
    Caused by: java.lang.IllegalArgumentException: Cannot create binary debugFramework: binary with such a name already exists
    error that appears when adding the Cocoapods plugin and added this
    cocoapods {
            pod("AFNetworking")
    }
    section. Am I missing something?
    k
    j
    +2
    • 5
    • 29
  • d

    drofwarcs

    01/08/2021, 9:02 PM
    I have a KMM project with targets for Android/iOS only. Whenever I invoke a test from commonMain from the IDE gutter it defaults to running the
    cleanIosTest iosTest
    gradle tasks. I can edit the configuration of past tests to use a different gradle task but am curious if there is a way to have the tests that are started from the gutter to use a different gradle task?
    r
    • 2
    • 2
  • l

    ludOS

    01/09/2021, 1:34 PM
    Hi everybody 👋 I'm proposing an open source (LGPL) KMM app targeting iOS and Android. As I did it as a hobbie and because my ticket for the KotlinConf workshop was cancelled per Covid (I do hail from Montréal), I didn't have time to really talk about or document it. The source is there: https://github.com/f8full/herdr I'm glad to be here because I have a lot of questions, I tried to integrate MokoMvvn and could never figure out the iOS setup.
    a
    • 2
    • 4
Powered by Linen
Title
l

ludOS

01/09/2021, 1:34 PM
Hi everybody 👋 I'm proposing an open source (LGPL) KMM app targeting iOS and Android. As I did it as a hobbie and because my ticket for the KotlinConf workshop was cancelled per Covid (I do hail from Montréal), I didn't have time to really talk about or document it. The source is there: https://github.com/f8full/herdr I'm glad to be here because I have a lot of questions, I tried to integrate MokoMvvn and could never figure out the iOS setup.
And the Android alpha can be downloaded by joining this open group (anyone can join): https://groups.google.com/u/1/g/herdr-testers
https://github.com/f8full/herdr/pull/25
a

alex009

01/09/2021, 3:40 PM
all about moko-mvvm you can ask in github issues/discussions or in #moko 🙂
✔️ 1
l

ludOS

01/09/2021, 6:52 PM
oh, super thks!
View count: 5