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

    galex

    06/20/2019, 12:05 PM
    Hello, do we have something equivalent to the JVM classes java.net.URL and java.net.URLDecoder in common multiplatform code?
    d
    • 2
    • 2
  • f

    Fail

    06/20/2019, 12:20 PM
    UPD: (not KotlinxSerializer) io.ktor.client.features.json.serializer unresolved after update to 1.3.40
    Unresolved reference: serializer
    What changed?
    r
    • 2
    • 8
  • e

    egorand

    06/20/2019, 7:00 PM
    is any configuration required to enable JS test runner in a multiplatform project on 1.3.40? I’m looking into
    build/reports/tests/allTests
    after running
    check
    and I can only see tests executed on
    jvm
    and
    macosX64
    l
    j
    s
    • 4
    • 9
  • p

    pardom

    06/20/2019, 8:29 PM
    How can I change the name of the framework created with the cocoapods plugin. Is it as simple as editing the podspec?
    d
    • 2
    • 6
  • r

    russhwolf

    06/20/2019, 10:57 PM
    I’m having trouble updating Multiplatform Settings to 1.3.40. Seems to be an issue with the way I have tests in a separate module, which isn’t agreeing with something in the new JS defaults. Here’s a demo project that reproduces the issue based on the new project template: https://github.com/russhwolf/OneThreeForty. Clone project, run
    ./gradlew clean build check
    , and observe the output
    Execution failed for task ':kotlinNpmResolve'.
    > Cannot add a configuration with name 'OneThreeForty-lib-npm' as a configuration with that name already exists.
    l
    s
    j
    • 4
    • 6
  • d

    Dmitry Motyl

    06/21/2019, 9:31 AM
    If I create instance of Kotlin Class in Swift Code and have strong reference to it, I can see this instance in memory graph. I expected if I set null to reference, instance will be disposed. Unfortunately I see this instance in memory. Why GC doesn’t clear memory?
    k
    o
    s
    • 4
    • 43
  • h

    hooliooo

    06/21/2019, 9:50 AM
    I have networking callbacks with the following signature:
    fun someAPIRequest(input: String, callback: (SomeModel?, SomeError?) -> Unit) {
       ....
    }
    From what I read, Kotlin Native interoperability to iOS is Kotlin => Objective-C => Swift, correct? To change that into a Result type I’d implement something like:
    sealed class  SomeResult<T, E> {
        data class Success<T, E>(val value: T): SomeResult<T, E>()
        data class Failure<T, E>(val value: E): SomeResult<T, E>()
    }
    
    fun someAPIRequest(input: String, callback: (SomeResult<SomeModel, SomeError>) -> Unit) {
       ....
    }
    But then, I’d have to typecast in Swift, correct? I wouldn’t be able to leverage the Swift Result type because it’s a language feature right?
    👍 1
    k
    • 2
    • 1
  • c

    coletz

    06/21/2019, 1:23 PM
    Hi guys, I'm trying to build an app with mpp using also kotlin/js. I'm getting this weird error, anyone ever had this issue?
    r
    • 2
    • 3
  • s

    spierce7

    06/21/2019, 5:32 PM
    I just spent a few days converting my teams Android project that was using the
    kotlin-platform-x
    gradle plugins to use the
    multiplatform
    plugin. I'm now getting the following error in my builds. Does anyone have any recommendations? I'm a bit stuck now:
    > Task :app:lintVitalInternalRelease FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:lintVitalInternalRelease'.
    > Configuration with name 'compileClasspath' not found.
    r
    • 2
    • 3
  • j

    Jan Stoltman

    06/22/2019, 8:52 AM
    Is it possible to disable on of the default compilations? Eg.
    iosTest
    ?
    f
    • 2
    • 4
  • a

    alex009

    06/22/2019, 5:03 PM
    anyone know mpp (android & ios) library with datetime and timezones? analog of klock
    l
    f
    • 3
    • 3
  • m

    Matej Drobnič

    06/23/2019, 4:35 PM
    Is it possible to have normal module and multiplatform module in the same gradle project?
    e
    • 2
    • 12
  • s

    spierce7

    06/24/2019, 2:33 AM
    Using the
    multiplatform
    plugin, if I have test sourcesets dependOn other sourcesets, I can't access the
    internal
    code of those source sets. I have a sourceSet that is generated code, so I separate it, and those tests that depend on the generated code, and the common code can't access the internal code of the common source set. My configuration is inside the thread.
    • 1
    • 1
  • s

    sdeleuze

    06/24/2019, 8:07 AM
    Hey, thanks to @snrostov my https://github.com/sdeleuze/spring-kotlin-fullstack is now using the new MP Gradle plugin but I have to say I am puzzled by the dependency structure that seems rather not conventional and harder to understand that previous one. For the JS module, we have currently:
    kotlin {
        target {
            browser()
    
            sourceSets {
                main {
                    dependencies {
                        implementation(kotlin("stdlib-js"))
                        implementation(project(":shared"))
                    }
                }
            }
        }
    }
    Why not:
    kotlin {
        target {
            browser()
        }
    }
    dependencies {
            implementation(kotlin("stdlib-js"))
            implementation(project(":shared"))
        }
    For the common module, we have this pretty confusing build:
    kotlin {
        jvm()
        js {
            browser()
            nodejs()
        }
    
        sourceSets {
            commonMain {
                dependencies {
                    implementation(kotlin("stdlib-common"))
                }
            }
            commonTest {
                dependencies {
                    implementation(kotlin("test-common"))
                    implementation(kotlin("test-annotations-common"))
                }
            }
            getByName("jvmMain").apply {
                dependencies {
                    implementation(kotlin("stdlib-jdk8"))
                }
            }
            getByName("jvmTest").apply {
                dependencies {
                    implementation(kotlin("test"))
                    implementation(kotlin("test-junit"))
                }
            }
            getByName("jsMain").apply {
                dependencies {
                    implementation(kotlin("stdlib-js"))
                }
            }
            getByName("jsTest").apply {
                dependencies {
                    implementation(kotlin("test-js"))
                }
            }
        }
    }
    Is it the expected final format we are going to use? cc @gaetan
    s
    r
    +3
    • 6
    • 100
  • s

    Slackbot

    06/24/2019, 9:06 AM
    This message was deleted.
    y
    f
    k
    • 4
    • 13
  • d

    darkmoon_uk

    06/24/2019, 11:24 AM
    Really want to support a project with both an Android and Desktop Java source-set
    h
    c
    • 3
    • 3
  • f

    Fail

    06/24/2019, 2:06 PM
    Strange errors with sqldelight> Case: 1. Create new multiplatform (Android/IOS) project. 2. Add sqldelight: create folder, add plugin to gradle:
    buildscript {
        repositories {
            google()
            mavenCentral()
        }
        dependencies {
            classpath 'com.squareup.sqldelight:gradle-plugin:1.1.3'
        }
    }
    ...
    apply plugin: 'com.squareup.sqldelight'
    sqldelight {
        MyDatabase {
            packageName = "ru.mybase.database"
            sourceFolders = ["sqldelight"]
        }
    }
    ...
    kotlin {
    ...
    SourceSets {
            commonMain {
                dependencies {
                    implementation kotlin('stdlib-common')
                    implementation "com.squareup.sqldelight:runtime-metadata:1.1.3"
                }
            }
    ...
    All compiled and worked. 3. Add kotlinx serialization:
    buildscript {
    ...
        dependencies {
            --> classpath "org.jetbrains.kotlin:kotlin-serialization:1.3.40"
            classpath 'com.squareup.sqldelight:gradle-plugin:1.1.3'
        }
    }
    ...
    apply plugin: 'kotlinx-serialization'
    ...
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.11.1"
    ...
    And we have error:
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.squareup.sqldelight:runtime-jvm:1.1.3.
    After removing serialization plugin the error remains. Tested with enableFeaturePreview("GRADLE_METADATA") and without.
    y
    b
    c
    • 4
    • 13
  • k

    kpgalligan

    06/24/2019, 6:29 PM
    Any chance there will be a 1.3.0-M1 update for Kotlin 1.3.40? Can’t deploy some libraries until that’s available.
    ➕ 1
    ⭐ 4
    e
    • 2
    • 1
  • p

    pardom

    06/24/2019, 8:48 PM
    Perhaps like this?
    presets.withType<KotlinNativeTargetPreset>().forEach { preset ->
        targetFromPreset(preset)  {
            val main by compilations.getting {
                dependencies {
                    api("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.2.2")
                }
            }
        }
    }
    b
    • 2
    • 15
  • c

    capitalthree

    06/24/2019, 9:27 PM
    can anyone point me to any example of a gradle kotlin multiplatform project that has a subproject? Even if nobody can give me a specific answer about scala, I am pretty sure I can make it work as a subproject but I don't know how to make the jvm compile task include the subproject properly
    b
    • 2
    • 54
  • p

    pardom

    06/25/2019, 1:07 AM
    I have all my tests in
    commonTest
    . Is it possible to choose just one target to run the tests?
    b
    r
    • 3
    • 5
  • p

    pardom

    06/25/2019, 1:16 AM
    Uh… maybe it’s been fixed with the test runner updates in 1.3.40?
    • 1
    • 1
  • g

    galex

    06/25/2019, 5:38 AM
    Hello, does someone have an example of a Multiplatform project that runs common unit tests on its Android library target? Since
    1.3.40
    to just compile I had to add the following in the root level dependencies block:
    testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
        testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
    Running the gradle task
    build
    , which runs the tasks
    testDebugUnitTest
    fails:
    > Task :testDebugUnitTest FAILED
    
    com.mu51k.core.util.EmailUtilsTests > emailsAreInvalid FAILED
        java.lang.NullPointerException at EmailUtilsTests.kt:20
    
    com.mu51k.core.util.EmailUtilsTests > emailsAreValid FAILED
        java.lang.NullPointerException at EmailUtilsTests.kt:12
    
    2 tests completed, 2 failed
    The NPE seems weird, as the code looks like that:
    assertTrue { "<mailto:glfala@fefr.com|glfala@fefr.com>".emailValid() }
    And
    emailValid()
    on Android is the following:
    actual fun String.emailValid(): Boolean = Patterns.EMAIL_ADDRESS.matcher(this).matches()
    Any idea?
    g
    • 2
    • 6
  • s

    Slackbot

    06/25/2019, 2:06 PM
    This message was deleted.
    t
    • 2
    • 1
  • a

    adiba

    06/25/2019, 3:50 PM
    Hi everyone! I’m a native Android Engineer in London and very new to the multi platform landscape. I am currently thinking how possible it is to scale apps with this approach. Most talks I’ve seen focus on a single shared module. Does anyone know if it possible to have multiple shared modules vs a potential shared monolith?
    p
    • 2
    • 3
  • g

    galex

    06/25/2019, 4:08 PM
    Hey, can I build a . Framework containing both architectures for the emulator and the iPhone?
    j
    k
    • 3
    • 6
  • k

    kieran

    06/26/2019, 3:57 AM
    Just to clarify, I understand DI well enough, but I wouldn’t know how to provide, say, the equivalent of a Dagger module that injects library objects with platform implementations. I wonder if I’m overthinking it, or if anyone could point me to an example of a good way to achieve this goal.
    d
    k
    • 3
    • 8
  • c

    coletz

    06/26/2019, 6:31 AM
    I have a multiplatform project with kotlin js and I need to use kotlin 1.3.31. Right now intellij idea creates a configuration which uses kotlin 1.3.40 and some stuff which are not available before this version. I am talking about these: 1)
    kotlin{
      ...
       js {
        browser {
        }
      }
    }
    2)
    jvmBackendJar {
        dependsOn(jsBrowserWebpack)
        from(new File(jsBrowserWebpack.entry.name, jsBrowserWebpack.outputPath))
    }
    how can I replicate these tasks without kotlin 1.3.40? Can someone share an older mpp config with js? Thanks 🙂
    h
    • 2
    • 2
  • a

    adiba

    06/26/2019, 1:58 PM
    Anyone know any good projects or blogs on successfully setting up unit tests on (MPP) iOS and Android?
    p
    • 2
    • 3
  • k

    Kris Wong

    06/26/2019, 3:45 PM
    what is the specific technical limitation that prevents multiple MPP frameworks in an iOS app?
    b
    p
    o
    • 4
    • 14
Powered by Linen
Title
k

Kris Wong

06/26/2019, 3:45 PM
what is the specific technical limitation that prevents multiple MPP frameworks in an iOS app?
b

basher

06/26/2019, 3:46 PM
There's a runtime assertion that fires when you load the 2 frameworks about not allowing 2 K/N runtimes to run
https://github.com/JetBrains/kotlin-native/issues/2423
k

Kris Wong

06/26/2019, 3:46 PM
thank you!
though I am still curious what the actual limitation is
i see the "closed world" compilation model explanation.
b

basher

06/26/2019, 3:55 PM
i think at the moment, it has more to do with the vision and less about technical limits, but now that everything is designed this way, it may take work to get out of that world, if JB is so inclined
k

Kris Wong

06/26/2019, 3:59 PM
it definitely adds a lot of overhead for organizations that want to invest in Kotlin MPP
creating and maintaining each of these "umbrella" projects for each app
b

basher

06/26/2019, 4:01 PM
we're working around it by using "export" thing here: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html
p

pardom

06/26/2019, 4:13 PM
There is overhead for sure, but I wouldn’t say a lot. I have my common code broken out into subprojects and have a buildscript in their root to combine them into a single MPP project: https://github.com/pardom/lambda-news/blob/master/common/build.gradle.kts
k

Kris Wong

06/26/2019, 4:27 PM
a buildscript is definitely helpful
my gradle fu isn't particularly strong
o

olonho

06/26/2019, 9:29 PM
Generally, we suggest modularisation on klib level and single framework at the end
k

Kris Wong

06/26/2019, 9:32 PM
will have to find the best practice for doing so
View count: 4