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

    Xavier Lian

    10/04/2019, 1:56 AM
    I’m trying to flesh out some architecture for MVVM, but I’m not entirely sure how to bind viewmodels (VMs) to views. My questions are best asked through an example. So here’s a simple VM:
    class MyVM(
        private val vmDidSummonLoadingScreen: () -> Unit,
        private val vmDidDismissLoadingScreen: () -> Unit
    )
    {
        fun doAFlip() 
        {
            vmDidSummonLoadingScreen()
            startSuperLongAsyncTask {
                vmDidDismissLoadingScreen()
            }
        }
    }
    Here’s some example UI in Android
    class FMMain: Fragment()
    {
        val loadingScreenVw: View get() = fm_main_vw_loading_screen	//From XML
    
        val vm: MyVM by lazy {                                //Problem a1
            MyVM(
                vmDidSummonLoadingScreen = {                  //Problem a0
                    loadingScreenVw.visibility = View.VISIBLE
                },
                vmDidDismissLoadingScreen = {                 //Problem a0
                    loadingScreenVw.visibility = View.GONE
                }
            )
        }
    
        override fun onCreate(...)
        {
            super.onCreate(...)
            vm.doAFlip()
        }
    }
    Problems: a0: The lambdas will leak the instance of FMMain since the lambdas reference a property of FMMain thereby implicitly capturing it. a1: Assuming the lambdas don’t leak, when the device rotates, the UI dies and so does the VM. There is the Android Component Library ViewModel class that solves this, but that can’t be used in the shared module. iOS is excluded because this architecture works pretty well since Swift has [weak self] to prevent strong captures. So my questions are: 1: How does one release lambda captures? 1.1: If not possible, what is the best way to let the UI layer know that an event happened in the VM without using any external libs/dependencies (just idomatic kotlin)? 2: Only in Android, I am considering wrapping my VM with an object that inherits from Android’s Architecture Components’ ViewModel (possibly generic idk if I can do that yet). Is there a better alternative in your opinion? 3. In your opinion, should VMs be injected into Fragments, or should Fragments instantiate and own their own VMs?
    a
    n
    7 replies · 3 participants
  • n

    napperley

    10/04/2019, 2:35 AM
    Is it possible to generate reference documentation for a MPP library?
    y
    i
    3 replies · 3 participants
  • b

    Big Chungus

    10/04/2019, 3:55 PM
    When using maven-publish plugin with MPP project, how do i publish transitive dependencies metadata? e.g.: I have module A and core module B that depends on A. I publish both and include module B to some project, but module A is not added as module B dependency to that project
    i
    2 replies · 2 participants
  • n

    Nikky

    10/05/2019, 7:33 PM
    does anyone know of a multiplatform UI abstraction layer? in particular something that allows me to create the same tabs, textfields, dropdowns, etc in html/js and tornadofx ? (and potentially android/iOS later)
    d
    j
    6 replies · 3 participants
  • k

    Konstantin Petrukhnov

    10/07/2019, 6:28 AM
    What is suggested way of creating singletons that will work on ios/jvm?
    s
    m
    +1
    22 replies · 4 participants
  • k

    Kris Wong

    10/08/2019, 6:54 PM
    man I can't believe I waited this long to switch my MPP build scripts to Kotlin DSL. so much nicer.
    :kotlin-flag: 2
    💪 1
    1 reply · 1 participant
  • k

    kpgalligan

    10/08/2019, 7:33 PM
    Any good multiplatform examples with Kotlin dsl instead of Groovy? I’ve been holding off on the conversion but it’s probably time.
    k
    s
    +4
    11 replies · 7 participants
  • k

    Kris Wong

    10/09/2019, 3:27 PM
    has anyone had issues with this:
    apply(plugin = "com.android.library")
    in build scripts written in Kotlin DSL?
    a
    l
    24 replies · 3 participants
  • s

    Sujit

    10/09/2019, 8:25 PM
    Is there a blog post or sample app utilizing gradle kotlin DSL to publish KMP library (android and iOS) to bintray?
    k
    s
    +3
    15 replies · 6 participants
  • a

    ankushg

    10/10/2019, 6:26 PM
    Also -- just wanted to confirm that
    @OptionalExpectation
    only works for annotations at the moment, and doesn't automatically create no-op implementations for interfaces, right?
    d
    l
    2 replies · 3 participants
  • a

    Abel

    10/11/2019, 7:05 AM
    Hey! was wondering how to mock objects in a unit test for IOS since mockk doesn’t support that yet?
    b
    2 replies · 2 participants
  • m

    mkojadinovic

    10/11/2019, 10:37 AM
    Hey guys, I was wondering how I can annotate fun to be static for objective-c, similar like we have @JvmStatic?
    s
    4 replies · 2 participants
  • d

    diesieben07

    10/11/2019, 8:19 PM
    I'm experimenting with extracting common logic into a common kotlin module, which I then compile to Javascript and want to consume in a typescript project (as an npm module). The dependency via NPM works, but I am unsure as to where I would put my typescript definition files. Tried putting them in
    jsMain/resources
    , but those files never show up in the NPM project that's generated by the gradle plugin. Moreover: I am applying the "multiplatform" plugin in a subproject, but the javascript npm projects are still generated in the top level project build folder and there is also an NPM project generated for the top level project (which does not have the multiplatform plugin!). The NPM project that actually contains my js code is put into
    build/js/packages/<root project name>-<subproject name>
    . How can I disable this? I just want a plain NPM project for the javascript code.
    i
    s
    20 replies · 3 participants
  • n

    Nikolai

    10/13/2019, 4:37 PM
    Hello, everyone. I have an unusual question. What is the disadvantages or restrictions of Kotlin Multiplatform. Maybe you planned to use this approach but during implementation faced some troubles or problems? Or maybe you just know other side ( or sides ) of this technology? I am asking because I used it for three projects, but my experience is positive. I want to present this technique in my company and start using it. But I almost sure that question about disadvantages will be asked, I know that they exist, but I am not aware of them.
    s
    a
    +4
    7 replies · 7 participants
  • k

    kpgalligan

    10/13/2019, 5:35 PM
    Does anybody know if there’s a way to config library exports for native with cocoapods? You can config that on frameworks without cocoapods, but not sure with
    binaries {
        framework {
            export project(':dependency')
            // Export transitively.
            transitiveExport = true
        }
    }
    Config block from here: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html
    a
    f
    7 replies · 3 participants
  • k

    Konstantin Petrukhnov

    10/14/2019, 10:40 AM
    How to iterate over api dependencies? I want something like: configurations.api.files that will give list of all jars that are api dependency api and jvmApi gives error: "Resolving configuration 'jvmApi' directly is not allowed"
    g
    1 reply · 2 participants
  • k

    Kris Wong

    10/15/2019, 1:47 PM
    interesting commentary from Roman on multi-threaded coroutines: "To give you some more detail on what's holding us back. kotlinx.coroutines is a multiplatform library. Currently all the "multithreading-capable" data structures are part of JVM compilation only while Native and JS contains simple stubs. In order to support multi-threading on Native we need to share this code between JVM and Native, while leaving stubs for JS. Unfortunately, our current MPP model in Kotlin (which is still experimental) does not support this. We are working on its next version code-named "Hierarchical MPP" (HMPP) which enable this kind of fine-grained sharing."
    👍 1
    :kotlin-flag: 16
    s
    2 replies · 2 participants
  • t

    timm

    10/16/2019, 7:19 AM
    Where can I find the documentation for the new Kotlin JS Gradle Plugin? And can I use this in MPP?
    b
    r
    +2
    10 replies · 5 participants
  • r

    Robert Jaros

    10/16/2019, 1:24 PM
    how to add new source directory to
    commonMain
    sourceSet in multiplatform gradle project?
    k
    b
    10 replies · 3 participants
  • r

    Robert Jaros

    10/16/2019, 5:07 PM
    should compilation of a
    jvm
    target trigger the compilation of the
    commonMain
    ?
    :yes: 7
    d
    1 reply · 2 participants
  • d

    darkmoon_uk

    10/17/2019, 7:54 AM
    I read that the Multiplatform Plugin is supposed to compile only the targets requested of it, but Gradle is consistently building the (irrelevant) iOS Framework target, while building a depending Android project. 🐢 ⏱️ The Android project itself is not multiplatform - do I need to specify in the project dependency to only build the Android target?
    b
    k
    3 replies · 3 participants
  • f

    FranGSierra

    10/17/2019, 10:25 AM
    Hello! Fast question. It's possible to use Kotlin reflection in Kotlin Multiplatform? Only from common module, not on iOS or Android. Building at this moment a wrapper over Firebase Firestore and I want to cast a convert a class to a
    Map<Field,Value>
    for pass it to iOS library.
    g
    6 replies · 2 participants
  • l

    Lamberto Basti

    10/17/2019, 12:58 PM
    How do you get a reference to Jars downloded from maven for the JS target in Kotlin DSL? I need to unpack them for the assemble web! If i try to use
    configurations["jsApi"].singleFile
    it errors with:
    Resolving configuration 'jsApi' directly is not allowed
    1 reply · 1 participant
  • t

    taso

    10/17/2019, 6:48 PM
    We are using SQLDelight with Coroutines in a Kotlin Multiplatform project. Hope this is the right place to ask. We couldn't really fully grasp the limitations on Kotlin Native. Our iOS team has pending questions regarding performance and whether if we will actually be doing database I/O operation on main thread. Can someone enlighten me and point me to right direction? Thanks.
    👀 1
    k
    k
    +3
    50 replies · 6 participants
  • a

    Andy Gibel

    10/17/2019, 7:48 PM
    Differences between a few of these seem... subtle? Nonexistent?
    s
    a
    +2
    10 replies · 5 participants
  • f

    FranGSierra

    10/18/2019, 12:01 PM
    Any way to run all the tests from all the platforms at once? When I try to do an
    app -> Run all tests
    there are no tests founds. I need to run individually the folders of each platform and on iOS case I need to run the gradle script for it. Any idea about how to unify this?
    k
    s
    +1
    5 replies · 4 participants
  • z

    zceejkr

    10/19/2019, 8:17 AM
    Hello guys, I am trying to use UnsingedIntegers in my multi-platform project. I use it almost everywhere and I want to pass the compiler flag to avoid using annotations everywhere (https://kotlinlang.org/docs/reference/experimental.html#module-wide-use). I am also using the gradle kotlin-multiplatform and could someone tell me where I can put the compiler flag in the plugin?
    g
    13 replies · 2 participants
  • e

    eloew

    10/19/2019, 11:33 AM
    How to reference items from “android.app” and “android.util” (like Application or Log) in SharedCode/androidMain?
    r
    4 replies · 2 participants
  • m

    mzgreen

    10/19/2019, 2:49 PM
    Now I’m struggling with
    NoClassDefFoundError
    in jvm module. It doesn’t see the class from shared module 🤔
    r
    d
    3 replies · 3 participants
  • c

    CRamsan

    10/21/2019, 4:50 AM
    Hello everyone. Does someone know if there is a link to the API documentation for the kotin-multiplatform plugin? I am aware of this page: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html but I am looking more like the full DSL documentation similar to: https://google.github.io/android-gradle-dsl/ . Does such page exist?
    l
    k
    2 replies · 3 participants
Powered by Linen
Title
c

CRamsan

10/21/2019, 4:50 AM
Hello everyone. Does someone know if there is a link to the API documentation for the kotin-multiplatform plugin? I am aware of this page: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html but I am looking more like the full DSL documentation similar to: https://google.github.io/android-gradle-dsl/ . Does such page exist?
l

louiscad

10/21/2019, 4:55 AM
The page you have is the most up to date and complete doc yet. Other than that, autocomplete in kts gradle scripts can help you.
k

Kris Wong

10/21/2019, 1:37 PM
i have found that code navigation is indispensable for this purpose
View count: 2