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

    aaverin

    01/13/2020, 11:54 AM
    On KotlinConf, in the keynote, it was on the slides that DateTime API is coming to MPP. Was it released already?
    m
    k
    +2
    • 5
    • 4
  • j

    Jue

    01/13/2020, 10:39 PM
    Any suggestions for Multiplatform XML parsing library ? If not how to handle in multiplatform project where the only input option is XML. Thanks.
    k
    l
    • 3
    • 5
  • v

    Vasili

    01/14/2020, 9:22 AM
    Hello! Simple question but I didn't find it by googling. Are default values supported for functions/constructors in Koltin Multiplatform compiled into iOS target for using in Swift? Can I use default implementation of
    NetworkClient
    in common code to be able to change this client in Swift or leave default?
    class GetOrganizations(
        private val network: NetworkClient = KtorNetworkClient()
    ) : Action<Params, List<Organization>>
    d
    • 2
    • 2
  • s

    sikri

    01/14/2020, 9:51 AM
    Is it possible to build Kotlin/MPP projects without Gradle? Are there any compilers, shell scripts, etc, that allow to build a project without Gradle plugin? Is there anything, like, let me call it, Core Kotlin, that is used only as
    common
    code? Being able to use keywords `expect`/`actual` only in pairing (Core Kotlin - target platform), are those words considered as part of some Core Kotlin, or as a part of that gradle mpp plugin, as there would be no sense to use it without that plugin?
    b
    k
    • 3
    • 6
  • b

    Big Chungus

    01/14/2020, 2:09 PM
    Getting
    Duplicate JVM class name
    on MPP project with
    common
    and
    JVM
    sourceSets dectaring
    expect/actual
    fun some(a:Int, b:Any)
    . Any suggestions?
    d
    d
    • 3
    • 5
  • d

    dambakk

    01/14/2020, 2:10 PM
    My company is considering creating a mpp library to share data models exposed by our backend api with the frontend. The backend uses Spring Boot and Jackson and the frontend (which is also a mpp project) uses kotlinx.serialization. How will this work? And how do we solve Jackson specific annotations like
    @JsonFormat(pattern = "yyyy-MM-dd")
    ?
    d
    u
    • 3
    • 4
  • s

    Sylvain Patenaude

    01/14/2020, 7:03 PM
    In my Kotlin MP project, the jvm target generates an output name such as this: MyProject*-jvm*.jar. How would I configure it to not have the -jvm suffix?
    k
    u
    d
    • 4
    • 17
  • y

    yshrsmz

    01/15/2020, 3:35 AM
    anyone here knows any logging library which supports Worker? I looked at some libs(Napier, klogger and Multiplatform-Log), but all of them seems to be using mutableList or threadlocal
    d
    • 2
    • 2
  • j

    Joey

    01/16/2020, 5:21 AM
    I am planning to create a foreground service to my android target. What would be the approach here if i will be creating the core function in my kotlin multiplatform lib? Thanks
    r
    • 2
    • 1
  • j

    Joey

    01/16/2020, 7:30 AM
    Is there a way to use real time data base in my kotlin mpl?
    t
    • 2
    • 3
  • a

    Andrei Marshalov

    01/16/2020, 10:29 AM
    Hello, do someone have an actual example of using
    ktor
    in multiplatform (iOS/Android) library? I’m interested in downloading files with http client. Thank you in advance!
    k
    • 2
    • 1
  • b

    Big Chungus

    01/16/2020, 3:14 PM
    So I've been working on a sample project showcasing the power and sample setup for kotlin multiplatform and here it is if anyone's interested! https://gitlab.com/kotlin-examples/game-of-life-mpp It currently implements a simple GUI app for JS, WASM, Linux & Windows (possibly MacOS as well, haven't tested it yet). Feel free to submit MRs if you see room for improvements :)
    👏 7
    r
    • 2
    • 4
  • s

    Sylvain Patenaude

    01/16/2020, 4:18 PM
    I wrote an SDK that is only comprised of static methods. At first I had those methods wrapped in objects like this:
    // File 'Name3.kt'
    package name1.name2
    
    object Name3 {
        fun Function1(): String {...}
    }
    After, I removed the "object" layer, thinking I would simplify client calls. However, when calling my Android/jvm SDK from a Java client, for instance, it looks awkward since Java doesn't support package-level functions. So it looks like this from the Java client:
    import name1.name2.Name3Kt;
    
    void func() {
        String s = Name3Kt.Function1();
    }
    Based on that, shouldn't I revert to my 1st solution of having my static functions wrapped in an object, so the client call (in Java) would look like this instead?
    import name1.name2.Name3Kt; //SDK functions at package-level
    import name1.name2.Name3;     //SDK functions at object-level
    
    String s = Name3Kt.Function1(); //SDK functions at package-level
    String s = Name3.Function1();     //SDK functions at object-level
    d
    • 2
    • 4
  • b

    bod

    01/16/2020, 6:03 PM
    Hello, World! Does anyone know if it's possible to have a MP project that both publishes an Android library artifact (.aar), and contains an Android app sample. It appears to me that I find samples that either apply the
    com.android.library
    gradle plugin (to publish an aar artifact) or the
    com.android.application
    one (to have a sample app) - but of course you can't apply both. Ideas?
    b
    s
    • 3
    • 13
  • v

    vanniktech

    01/16/2020, 6:19 PM
    On iOS I’ve got
    -Xobjc-generics
    enabled. However when trying to run a release build I get:
    cannot specialize non-generic type
    Seems like Kotlin Generics are only working for debug builds. Is there any additional config needed?
    k
    • 2
    • 3
  • s

    Sam Schilling

    01/16/2020, 7:33 PM
    Is there a way to make only some functions in a class platform-specific? The following gives me an error that
    baz
    must be abstract since it has no body:
    class Foo {
        fun bar() { ... }
        expect fun baz(): Boolean
    }
    d
    k
    • 3
    • 4
  • a

    Arkadii Ivanov

    01/16/2020, 11:13 PM
    Is there a way to share test code between modules? I want test code of module "A" to use test code from module "B". Tried
    java-test-fixtures
    plugin but it does not seem to work in MPP environment.
    k
    r
    n
    • 4
    • 10
  • o

    Olenyov Kirill

    01/17/2020, 4:29 PM
    Hi everyone, how to add “-Xobjc-generics” with cocoapods framework creating?
    k
    • 2
    • 2
  • t

    Tristan

    01/17/2020, 5:43 PM
    Is there something like this available in kotlin?
    if #available(iOS 9.0, *) {
        // use UIStackView
    } else {
        // show sad face emoji
    }
    
    @available(iOS 9.0, *)
    func useStackView() {
        // use UIStackView
    }
    👀 1
    m
    • 2
    • 1
  • l

    Lulu

    01/18/2020, 1:04 AM
    I'm implementing a custom map for cache, and thinking of ways to make it grow as much as memory allows (or something similar, I just don't want to set a fixed size that could turnout to be useless). I thought of
    WeakReference
    but some of my team advised against it. Any suggestions or takes on this matter? We target JVM and Native.
    👀 2
    d
    • 2
    • 2
  • s

    sikri

    01/18/2020, 8:13 AM
    Did anyone manage to run spring boot as a jvm module of mpp project? build.gradle.kts plugins:
    id("org.springframework.boot") version "2.2.3.RELEASE"
        kotlin("plugin.spring") version "1.3.61"
        kotlin("plugin.allopen") version "1.3.61"
        kotlin("multiplatform")
        kotlin("kapt")
        id("kotlinx-serialization")
    
    
    apply(plugin = "io.spring.dependency-management")
    sourceSets:
    sourceSets {
            val jvmMain by getting {
                kotlin.srcDir("src")
                resources.srcDir("resources")
            }
            dependencies {
    
        implementation(project(":common"))
    
        implementation("org.springframework.boot:spring-boot-starter-web:2.2.3.RELEASE")
        implementation("org.springframework.boot:spring-boot-configuration-processor:2.2.3.RELEASE")
        configurations["kapt"].dependencies.add(
            DefaultExternalModuleDependency(
                "org.springframework.boot",
                "spring-boot-configuration-processor",
                "2.2.3.RELEASE"
            )
        )
       }
    }
    Idea doesn’t see generated classes (fun main), theefore I’m running via custom run task:
    task<JavaExec>("run") {
        main = "com.example.mpp.backend.AppRunner"
        val jvm by kotlin.targets.getting
        val main: KotlinCompilation<KotlinCommonOptions> by jvm.compilations
    
        val runtimeDependencies = (main as KotlinCompilationToRunnableFiles<KotlinCommonOptions>).runtimeDependencyFiles
        classpath = files(main.output.allOutputs, runtimeDependencies)
    }
    But dependencies of Spring don’t see application.yml in this case, and therefore app cannot be started
    r
    • 2
    • 9
  • o

    Olenyov Kirill

    01/18/2020, 10:51 AM
    Question regarding obj-c <-> swift interop. In K/N I created two methods:
    fun test1(): List<Channel> {        
    }
    
    fun test2(): MWResponse<List<Channel>> {
    }
    Where Channel and MWResponse are just data and sealed classes. In generated obj-c header I see:
    - (NSArray<CommonChannel *> *)test1 attribute((swift_name("test1()")));
    - (CommonMWResponse<NSArray<CommonChannel *> *> *)test2 attribute((swift_name("test2()")));
    Looks good. “List<Channel>” was converted to obj-c “NSArray<Channel>” But in Swift these methods shown as:
    [Channel] test1()
    MWResponse<NSArray> test2()
    So two questions: 1) Why it has two different “array” types: [] and NSArray? 2) Where is generic type for test2() method? It should be NSArray<Channel> i think.. Is it a problem in objc-swift interop or mpp problem?
    a
    s
    n
    • 4
    • 5
  • b

    basher

    01/18/2020, 9:20 PM
    anyone have success getting IntelliJ to recognize iosMain and have autocomplete work there in Kotlin 1.3.60?
    • 1
    • 1
  • k

    kevin.cianfarini

    01/18/2020, 11:30 PM
    can anyone give me some guidance on how I would do annotation processing for a MPP?
    r
    d
    • 3
    • 3
  • k

    kevin.cianfarini

    01/18/2020, 11:38 PM
    follow up question...is it possible to write a module in completely common kotlin and add it to any project? Or do I have to explicitly declare jvm/js/linux/ios/etc
    d
    r
    • 3
    • 5
  • o

    Ola Adolfsson

    01/19/2020, 9:38 PM
    Hi all, I recently upgraded to Kotlin 1.3.61 and some of my js test fails due to: “`No binary for ChromeHeadless browser on your platform."` Has anyone encountered something similar?
    a
    • 2
    • 3
  • d

    darkmoon_uk

    01/20/2020, 7:36 AM
    When opening the composite build project, composed-in dependencies aren't resolved properly by the IDE (highlighted red), even though the Gradle build can succeed.
    ‼️ 1
    l
    a
    t
    • 4
    • 7
  • s

    sikri

    01/20/2020, 10:06 PM
    If I create an object in swift, that is defined in kotlin/common or kotlin/ios module, is it considered frozen by defauly?
    k
    • 2
    • 3
  • m

    Maurice Jouvet

    01/21/2020, 7:39 AM
    I have an Android application using Dagger2 as DI. I am currently using @Inject whenever I can, this application is already working very fine and is very efficient. Now I want to use this one with KMP. I have started to migrate some part of the application, but I am stuck with the classes with @Inject constructor. Do I have to remove all these to use generic constructor and let the DI on the platform specific, or is there another solution?
    m
    f
    k
    • 4
    • 16
  • n

    nrobi

    01/21/2020, 7:45 AM
    Anyone having the same problem?
    Unable to resolve dependency for ':common@debug/compileClasspath': Could not resolve io.ktor:ktor-client-ios:1.3.0.
    j
    m
    k
    • 4
    • 6
Powered by Linen
Title
n

nrobi

01/21/2020, 7:45 AM
Anyone having the same problem?
Unable to resolve dependency for ':common@debug/compileClasspath': Could not resolve io.ktor:ktor-client-ios:1.3.0.
j

Joey

01/21/2020, 7:47 AM
Have u tried
io.ktor:ktor-client-native:1.3.0
?
n

nrobi

01/21/2020, 7:48 AM
yes, the same issue
however it works with
io.ktor:ktor-client-ios:1.0.1
m

Maurice Jouvet

01/21/2020, 7:56 AM
Weird it’s working for me with this version.
n

nrobi

01/21/2020, 10:19 AM
What gradle version are you using?
k

Kris Wong

01/21/2020, 1:57 PM
1.3.0 works for me
View count: 9