https://kotlinlang.org logo
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
  • s

    saket

    05/31/2020, 7:11 AM
    I find it useful to have a native source set that iOS, macOS et al can depend on
    z
    l
    +2
    • 5
    • 8
  • k

    kevin

    05/31/2020, 10:45 PM
    any caveats when modularising a MPP project?
    s
    d
    +4
    • 7
    • 10
  • m

    Mars

    06/01/2020, 2:14 PM
    Hello there, am I right in thinking that adding jvm target like so
    kotlin {
      jvm()
    }
    would create
    jvmMain
    source set? I then declare dependencies for the source set in the following way
    jvm().compilations["main"].defaultSourceSet {
        dependsOn(commonMain)
        dependencies {
        ...
        }
    }
    but I can't make this very simple project run. I'm getting
    SourceSet with name 'jvmMain' not found.
    For details, please check: https://stackoverflow.com/questions/62132959/sourceset-with-name-jvmmain-not-found
    c
    • 2
    • 11
  • p

    Piasy

    06/01/2020, 2:44 PM
    Hi guys, I encountered a link error when I try to build Kotlin code into a static library, then link it into a iOS framework for simulator architecture (
    x86_64
    ), bunch of undefined reference to symbols like
    ___res_9_p_type_syms
    ,
    _BZ2_bzWriteClose
    ,
    _CKRecordShareKey
    ,
    _kCLLocationCoordinate2DInvalid
    ,
    _compression_stream_init
    and
    _at_encoder_get_block_alpha
    . I managed to add some libraries to fix all of them except for
    _at_encoder_get_block_alpha
    . I'm using Kotlin 1.3.71, there is no error at all on 1.3.61.
    s
    a
    • 3
    • 6
  • z

    zalewski.se

    06/01/2020, 4:28 PM
    I’m trying to do DI with Koin on KMP. I got stuck a little on iOS side. How can I get
    KotlinKClass
    type of my class generated from KMP module? I need to pass it as an argument to get an instance.
    m
    • 2
    • 1
  • a

    aleksey.tomin

    06/01/2020, 5:49 PM
    I try to use ktor-client + gson in MP project. In build.gradle.kts I’ve wrote:
    common:
                    implementation("io.ktor:ktor-client-core:$ktorVersion")
                    implementation("io.ktor:ktor-client-json:$ktorVersion")
                    implementation("io.ktor:ktor-client-gson:$ktorVersion")
    macOS:
                    implementation("io.ktor:ktor-client-curl:$ktorVersion")
                    implementation("io.ktor:ktor-client-core-native:$ktorVersion")
                    implementation("io.ktor:ktor-client-json-native:$ktorVersion")
    But when I write
    import io.ktor.client.features.json.GsonSerializer
    I have got the error
    Unresolved reference: GsonSerializer
    What I’ve done wrong?
    r
    • 2
    • 1
  • o

    Omar Mainegra

    06/01/2020, 8:23 PM
    Hi folks, I posted this in #kotlin-native but I couldn't get any answer. How can I run the RELEASE configuration for the iOS tests?  I can't even find the option to link it, just the debug one (
    linkDebugTestIos
    )
    • 1
    • 2
  • z

    zalewski.se

    06/02/2020, 4:05 PM
    Does anyone knows why if I will set iOS target like this:
    val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
            if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
                ::iosArm64
            else
                ::iosX64
    
        iOSTarget("ios") {
            binaries {
                framework(uniqueName)
            }
        }
    Then everything works in
    iosMain
    , I can see whole syntax highlighting correctly. Although if I set it like here:
    ios {
            binaries {
                framework(uniqueName)
            }
        }
    Everything related to iOS is red, I can’t see any import (although it compiles correctly) and syntax highlighting is broken.
    r
    k
    • 3
    • 13
  • j

    Justin

    06/03/2020, 3:44 AM
    Are there any examples of a Kotlin Multiplatform project that has platform-specific build targets (e.g.
    js
    ) but also builds a multiplatform library that can be imported into another Kotlin Multiplatform project? Basically I have KMP libraries
    A
    and
    B
    . Library
    A
    is imported directly by an external
    js
    project. Library
    B
    - which is used by native iOS and Android apps, requires library
    A
    as a dependency. Both libraries are for internal use only so I wouldn't be publishing anything to public maven. Any pointers would be much appreciated!
    r
    m
    • 3
    • 2
  • j

    Jolas

    06/03/2020, 3:51 AM
    Hi guys, I have a kotlin multiplatform project that is used as a module in iOS app and Android app to act as Data Repository. I am trying to implement a method to upload files in this KMP Module that can be accessed from iOS app code and Android App Code. Is there any documented way or some blog posts that help this scenario?
    r
    • 2
    • 5
  • m

    Mananpoddarm

    06/03/2020, 6:28 AM
    is it possible to use 3rd party libraries which are say platform specific? For example, tensorflow lite which is used in android/iOS. Iam including tensorflow lite as a dependency in jvmMain but I am not able to import it in my samplejvm.kt inside commonJVM module.
    g
    k
    • 3
    • 14
  • f

    felislynx

    06/03/2020, 7:19 AM
    Hi, i would like to ask how to handle Coroutines on ios side. In my shared library api calls look like this
    fun apiCall() = GlobalScope.async(ApplicationDispatcher) {..}
    so in Android code i can do val returnValue = apiCall().await() how to handle same flow in iOS ? I see that return type for this function is
    Kotlinx_coroutines_coreDeferred
    but there is no await() function available
    r
    • 2
    • 1
  • c

    Chetan Sachdeva

    06/03/2020, 5:47 PM
    Has anyone tried integrating FCM in a KMP project? A reference implementation would help. Thanks in advance 🙂
    s
    r
    • 3
    • 4
  • b

    bsimmons

    06/03/2020, 6:15 PM
    Are there any gradle templates for building iosArm64 and iosX64 targets at the same time so that they can be publish to maven local as projectname-native? (Currently I keep switching between the two for testing and release.) I've looked at different build.gradle files from Okio, kotlinx.serialization, and read through the spec but I can't seem to figure this out how this works.
    k
    • 2
    • 3
  • e

    esdudnik

    06/03/2020, 9:36 PM
    Anybody know how to implement “timer” analog in multiplatform library?
    ticker
    (from kotlinx.coroutines.channels) are ony JVM based, and according to this https://github.com/Kotlin/kotlinx.coroutines/issues/540 I don’t see that they will be multiplatform
    h
    • 2
    • 3
  • s

    Simon Schubert

    06/03/2020, 10:12 PM
    🤯 I tried to google and search this slack but my jvm and android mpp project won't run. Android builds fine but for the jvm I click the green arrow button in my Main.kt main() function and get the following error: "Error: Could not find or load main class sample.MainKt". Is there something wrong with my gradle? Simplified version:
    plugins {
        id 'org.jetbrains.kotlin.multiplatform'
    }
    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android-extensions'
    apply plugin: 'com.squareup.sqldelight'
    
    kotlin {
        android("android")
        jvm("jvm")
    
        sourceSets {
            androidMain {
                dependencies {
                    implementation kotlin('stdlib')
                    implementation "com.squareup.sqldelight:android-driver:1.3.0"
                }
            }
            jvmMain {
                dependencies {
                    implementation kotlin('stdlib')
                    implementation "com.squareup.sqldelight:sqlite-driver:1.3.0"
                    implementation "org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.1"
                }
            }
        }
    }
    l
    m
    r
    • 4
    • 5
  • j

    janvladimirmostert

    06/03/2020, 10:15 PM
    I'm trying out Kotlin Multiplatform for the first time, i've used the IntelliJ New Module to create a JVM/JS project What is the correct way to add a new npm dependency that does have TypeScript support should i just add it in the jsMain in build.gradle
    jsMain {
                dependencies {
                    implementation kotlin('stdlib-js')
                    implementation npm('lit-html', '1.2.1')
                }
            }
    or should i rather do
    mkdir lit-html-kt
    cd lit-html-kt
    npm init -y || exit
    sudo npm install -g dukat || exit
    npm install lit-html || exit
    dukat node_modules/lit-html/lit-html.d.ts || exit
    
    rm -rf ./*.json || exit
    rm -rf ./node_modules || exit
    which then generates kotlin files for this npm package ?
    j
    • 2
    • 2
  • a

    aiidziis

    06/04/2020, 9:52 AM
    Hey! Currently in MPP we are using SqlDelight and coroutines to insert data into db:
    class DbHelper(db: Db) {
        suspend fun insert(elements: List<Element>) = withContext(Dispatchers.Default) {
            db.elementQueries.transaction {
                db.elementQueries.insert(.....)
            }
        }
    }
    This works fine when elements list is not too big, but now we encountered use case where we need to insert larger amount of data (in worst case insert is 1200ms), and now this same approach is causing problems on iOS because this all happens on Main Thread(async) , and while the data is inserting UI is getting blocked when user interacts with UI (scrolling). Is there a way with current coroutines versions
    "1.3.5-native-mt"
    to improve this? afaik with current coroutines version it is not possible move insert to Background Thread?
    l
    k
    • 3
    • 7
  • m

    Matt Kranzler

    06/04/2020, 3:21 PM
    Hello, I'm just getting started with KMP and I'm using the KaMP kit to boostrap a project. I'm having issues with Intellij (2020.1.2) locking up any time I try to debug a unit test. If I run the test it will execute fine but as soon as I try to debug it will lock up Intellij completely and I have to force quit. I also tried Android Studio 4.0 and have the same issue. Has anyone else experienced this?
    r
    • 2
    • 2
  • j

    John O'Reilly

    06/04/2020, 9:05 PM
    Should there be a version of Kotlinx Coroutines (and in particular one that supports native multithreading) available yet that works with Kotlin 1.4-M2? (I guess most KMP projects are probably blocked from using it right now anyway until various other libraries are released that work with that version)
    k
    s
    +2
    • 5
    • 14
  • r

    Rachid

    06/05/2020, 2:40 PM
    I have a multiplatform project and am writing unit tests for common code. It appears that Mockk isn't supported yet. Does anyone know how to mock classes in common source sets?
    h
    a
    a
    • 4
    • 11
  • c

    ciriti

    06/06/2020, 8:44 AM
    Hi guys, do you know if it possible to use encryption with sqldelight?
    m
    m
    k
    • 4
    • 6
  • j

    janvladimirmostert

    06/06/2020, 12:37 PM
    Is it possible to mark certain classes / functions to be excluded from DCE? I'm trying to build a KotlinJS library that will be consumed by handwritten JavaScript and unless i specifically console.log that class, it gets removed by DCE
    @JsName("RoomState")
    data class RoomState(
        val numberOfRooms: Int
    )
    fun main() {
      console.log(RoomState::class)
    }
    which now allows me to do
    this.projectname.RoomState()
    in pure JS, i exclude that console.log, RoomState is not available
    c
    • 2
    • 5
  • k

    katokay

    06/06/2020, 3:23 PM
    Following the 1.4-M2 blog post to change some of my gradle setup for a multiplatform mobile project and I keep getting the error "KotlinTarget with name 'ios' not found." Any help to get this working would be appreciated! 1. Upgraded Kotlin IntelliJ plugin to the latest one from 1.4-M2 2. Create new Kotlin project using the experimental wizard, chose to use kts for the gradle files 3. Everything builds fine after this step 4. Added
    kotlin.mpp.enableGranularSourceSetsMetadata=true
    to gradle.properties file 5. Changed shared build.gradle.kts to have
    kotlin {
        android()
        ios()
        sourceSets {
            val commonMain by getting {
                dependencies {
                    implementation(kotlin("stdlib-common"))
                }
            }
            val commonTest by getting {
                dependencies {
                    implementation(kotlin("test-common"))
                    implementation(kotlin("test-annotations-common"))
                }
            }
            val androidMain by getting {
                dependencies {
                    implementation(kotlin("stdlib-jdk7"))
                    implementation("androidx.core:core-ktx:1.2.0")
                }
            }
            val androidTest by getting {}
        }
    }
    This is where I get the error in both IntelliJ and gradle cli. I've also verified the gradle plugin defined for the root build.gradle.kts is
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4-M2")
    and my gradle version is 6.5. I realize I might be misunderstanding something from the blog post, but hopefully someone can help clarify how this should work or look. Maybe pointing to a sample repo if one is available and known to work would help. The really odd behavior is that I can navigate from the IDE to the implementation of the ios target definition.
    z
    l
    • 3
    • 5
  • n

    natario1

    06/06/2020, 4:03 PM
    When running gradle multiplatform builds in CI (GitHub Actions), I get the warning
    Daemon will be stopped at the end of the build after running out of JVM memory
    , then the build hangs. Does anyone know how to enable more memory, and is there any official documentation about how much memory is required by the Multiplatform plugin? Builds without KMP work just fine.
    > Task :library:compileKotlinAndroidNativeArm32
    Downloading native dependencies (LLVM, sysroot etc). This is a one-time action performed only on the first run of the compiler.
    Downloading dependency: <https://download.jetbrains.com/kotlin/native/clang-llvm-8.0.0-linux-x86-64.tar.gz> (0 bytes/581.9 MiB). 
    Downloading dependency: <https://download.jetbrains.com/kotlin/native/clang-llvm-8.0.0-linux-x86-64.tar.gz> (140.4 MiB/581.9 MiB). 
    Downloading dependency: <https://download.jetbrains.com/kotlin/native/clang-llvm-8.0.0-linux-x86-64.tar.gz> (288.3 MiB/581.9 MiB). 
    Downloading dependency: <https://download.jetbrains.com/kotlin/native/clang-llvm-8.0.0-linux-x86-64.tar.gz> (425.8 MiB/581.9 MiB). 
    Downloading dependency: <https://download.jetbrains.com/kotlin/native/clang-llvm-8.0.0-linux-x86-64.tar.gz> (497.3 MiB/581.9 MiB). 
    Downloading dependency: <https://download.jetbrains.com/kotlin/native/clang-llvm-8.0.0-linux-x86-64.tar.gz> (580.1 MiB/581.9 MiB). 
    Downloading dependency: <https://download.jetbrains.com/kotlin/native/clang-llvm-8.0.0-linux-x86-64.tar.gz> (581.9 MiB/581.9 MiB). Done.
    Extracting dependency: /home/runner/.konan/cache/clang-llvm-8.0.0-linux-x86-64.tar.gz into /home/runner/.konan/dependencies
    Daemon will be stopped at the end of the build after running out of JVM memory
    e
    • 2
    • 2
  • a

    Andrew

    06/07/2020, 5:17 AM
    A MP library will obviously be consumed by multiple targets, but to start I'm not even sure how to do it for the first at the moment. I'd like my Android studio library to use this shared code but no idea what the workflow looks like. For example 1) Make a code change in shared library 2) ??? 3) Run android app with that code change. Currently I have a shared JVM gradle library I reference with a relative path in my settings.gradle so android studio sees that as a 2nd module and my code changes work seamlessly. Attempting the same with an MP project didn't work.
    e
    l
    • 3
    • 7
  • a

    Alexander Larsson

    06/08/2020, 9:54 AM
    Does anyone know if I can use the new 1.4 M2 Kotlin Plugin but still use an older version of Kotlin? The new project creator is really nice for setting up an MPP project so have been trying to use it but going back to an older Kotlin plugin version after project creation does not work for me.
    g
    r
    • 3
    • 5
  • a

    Alexander Larsson

    06/08/2020, 12:15 PM
    Does anyone know of any good seed project for an iOS/Android MPP Library? Something like https://github.com/Dallanosm/kotlin-multiplatform-seed but for iOS / Android library (I do not want the apps code to be in the project).
    s
    c
    j
    • 4
    • 5
  • t

    trevjones

    06/08/2020, 3:11 PM
    Is anyone aware of an mpp http/s server? The usecase is mock web server deployable to android/iOS/node to try and make things a bit more self contained in a test pipeline.
    c
    s
    • 3
    • 8
  • s

    saket

    06/08/2020, 5:54 PM
    is this what you’re looking for? https://youtrack.jetbrains.com/issue/KT-38685
    ⭐ 1
    j
    • 2
    • 1
Powered by Linen
Title
s

saket

06/08/2020, 5:54 PM
is this what you’re looking for? https://youtrack.jetbrains.com/issue/KT-38685
⭐ 1
j

jared

06/08/2020, 5:56 PM
Yes
View count: 9