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

    saket

    09/01/2019, 8:16 PM
    I know I can use Flow but this is a small side project and I'm trying to limit myself to familiar APIs.
    l
    • 2
    • 1
  • s

    saket

    09/01/2019, 10:54 PM
    Does anyone know if there any known issues in IntelliJ with adding dependencies on more than one multiplatform module? I have two local modules and IntelliJ seems to be only autocompleting only for the first one (featureA):
    implementation project(':featureA')
    implementation project(':featureB')
    s
    • 2
    • 4
  • j

    JoakimForslund

    09/02/2019, 8:40 AM
    Stupid question: If I have a multiplatform project, and want to make the commonMain of that project to import another commonMain from another module. Is this not the correct way of doing that
    implementation(project(":SharedGlobals"))
    ?
    s
    • 2
    • 4
  • c

    cafonsomota

    09/02/2019, 4:49 PM
    hello all, I’m trying to use sqldelight both on Android and iOS - but although everything is working fine on Android side, it seems when I attempt to generate the framework for iOS I’ve got a couple of errors on the generated db impl: example of generated insert method:
    override fun insertItem(city_name: String, country: String?) {
            driver.execute(117,
                    """INSERT OR FAIL INTO locationModel(city_name, country) VALUES (?1, ?2)""", 2) {
                bindString(1, city_name)
                bindString(2, country)
            }
            notifyQueries(database.locationModelQueries.selectAll)
        }
    and error:
    e: ...DbImpl.kt: (163, 23): Type mismatch: inferred type is MutableList<Query<*>> but Int was expected
    e: ...DbImpl.kt: (163, 62): No value passed for parameter 'queryList'
    and the .sq example that I’m trying to run is from a sample:
    CREATE TABLE locationModel (
        id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
        city_name TEXT NOT NULL,
        country TEXT
    );
    
    
    insertItem:
    INSERT OR FAIL INTO locationModel(city_name, country) VALUES (?, ?);
    
    
    selectAll:
    SELECT *
    FROM locationModel;
    
    deleteItem:
    DELETE FROM locationModel WHERE city_name = ?;
    any ideia what I might be doing wrong?
    m
    • 2
    • 2
  • d

    darkmoon_uk

    09/03/2019, 2:30 AM
    Any way to get Gradle to temporarily ignore one of the targeted platforms in Kotlin / MP ?
    g
    m
    +3
    • 6
    • 8
  • s

    Sam Garfinkel

    09/03/2019, 7:51 PM
    How can I configure a multiplatform JVM target to use a sibling JS target (maybe through the JsJar task?). My jvm target consists of a Ktor webserver which will serve some static JS generated by the JS target. I guess these could be separated into independent projects, but the JS target really only makes sense when served by the jvm target so I wanted to couple them together
    d
    b
    • 3
    • 7
  • m

    Michael Bryant

    09/03/2019, 9:41 PM
    hi! i was using the
    kotlin-multiplatform
    gradle plugin to compile a k/n app into iOS, android, and javascript. i just tried to update from
    1.3.40
    to
    1.3.50
    and my javascript build broke, since the
    compileKotlinJs
    and
    compileTestKotlinJs
    tasks stopped producing a
    package.json
    file. is there a way to get this file to be produced again? i can tell from the 1.3.50 release notes that the “structure and naming of generated artifacts” for JS has changed, but I can’t find these new artifacts anywhere
    m
    • 2
    • 1
  • j

    Jurriaan Mous

    09/04/2019, 9:19 AM
    Should internal methods/constructors be testable from Test module? In one module it does not work anymore after upgrading to 1.3.50 for JVM and JS (But still does for Native). I get a lot of
    Cannot access 'Class': it is internal in 'package.name'
    .
    j
    • 2
    • 4
  • k

    Kris Wong

    09/06/2019, 1:43 PM
    "Supporting multiple dependent frameworks (see discussion above) is much more complicated so I can't provide any specific details on this."
    r
    • 2
    • 2
  • l

    louiscad

    09/06/2019, 3:42 PM
    Is that a first step towards better integration of KMPP with Xcode projects? https://twitter.com/gradle/status/1169920641559957505?s=09
    ➕ 9
    😍 6
    g
    • 2
    • 1
  • w

    wuseal

    09/07/2019, 1:36 PM
    Hi, buddies, I notice an note this,It says that we need use export method to export dependencies into framework, And do I need to do that when I use
    implementation
    in dependencies config? https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#building-final-native-binaries
    s
    • 2
    • 5
  • e

    egorand

    09/08/2019, 1:06 PM
    My feeling is that custom source sets don’t really create separate compilation units under MPP, they just extend the default source sets but in the end get compiled into the same artifacts. Is this correct, or am I missing something?
    d
    h
    • 3
    • 9
  • j

    Justin

    09/08/2019, 9:09 PM
    Related to something I'm trying to do in a multiplatform project: https://kotlinlang.slack.com/archives/C7A1U5PTM/p1567976925031600
    d
    • 2
    • 2
  • l

    louiscad

    09/09/2019, 9:06 AM
    Can anyone link me a good or simple example of a multiplatform project that tests common code with common test sources on Android as an instrumented test?
    k
    m
    d
    • 4
    • 19
  • k

    Konstantin Petrukhnov

    09/10/2019, 10:17 AM
    I'm looking into possibility to have multipproject structure like on the picture:
    k
    a
    k
    • 4
    • 15
  • d

    Dominaezzz

    09/10/2019, 11:44 AM
    I've run into an issue where incorrect metadata is produced. The target names seem to have been made lowercase which doesn't match the actual published artefacts. https://github.com/Dominaezzz/kgl/issues/12#issuecomment-529889369 . Can plugin users somehow manipulate the output of the
    *.module
    files?
    • 1
    • 1
  • k

    Kris Wong

    09/10/2019, 1:24 PM
    i think i might know why my iOS source set is an ocean of red in the IDEA editor
    • 1
    • 2
  • d

    Darmaheev

    09/11/2019, 7:52 AM
    Hello everyone, I’m writing a multiplatform library that use in android and ios applications. To work with the database I decided to use sqldeligh. When i add the driver database in androidMain I need to use ‘’import android.content.Context import com.squareup.sqldelight.android.AndroidSqliteDriver’’, code:
    import android.content.Context
    import com.squareup.sqldelight.android.AndroidSqliteDriver
    
    lateinit var appContext: Context
    
    actual fun createDb(): MobileDatabase {
        val driver = AndroidSqliteDriver(MobileDatabase.Schema, appContext, "mobileDatabase.db")
        return MobileDatabase(driver)
    }
    My question is how to drag classes from SDKs into multiplatform libraries. My build.gradle:
    plugins {
        id 'org.jetbrains.kotlin.multiplatform' version '1.3.50'
        id 'kotlinx-serialization' version '1.3.50'
        id 'net.researchgate.release' version '2.6.0'
        id 'com.squareup.sqldelight' version '1.2.0'
        id 'com.android.library' version '3.5.0'
    }
    repositories {
        mavenLocal()
        google()
       mavenCentral()
    }
    group '***'
    version = "$version"
    
    apply plugin: "com.squareup.sqldelight"
    
    sqldelight {
        MobileDatabase{
            packageName = "***"
            sourceFolders = ["sqldelight"]
            schemaOutputDirectory = file("src/main/sqldelight/migrations")
        }
    
    }
    
    apply plugin: 'maven-publish'
    
    kotlin {
        def coroutine_version = "1.3.0"
        def ktor_version = "1.2.4"
        def serializer_version = "0.12.0"
        def sqldelight_version = "1.2.0"
    
        sourceSets {
            commonMain {
                dependencies {
                    api 'org.jetbrains.kotlin:kotlin-stdlib-common'
                    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutine_version"
                    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializer_version"
                    implementation "io.ktor:ktor-client-core:$ktor_version"
                    implementation "io.ktor:ktor-client-logging:$ktor_version"
                    implementation "com.squareup.sqldelight:runtime:$sqldelight_version"
                }
            }
            androidMain {
                dependencies {
                    api 'org.jetbrains.kotlin:kotlin-stdlib'
                    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
                    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
                    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializer_version"
                    implementation "io.ktor:ktor-client-android:$ktor_version"
                    implementation "io.ktor:ktor-client-logging-jvm:$ktor_version"
                    implementation "com.squareup.sqldelight:android-driver:$sqldelight_version"
                }
            }
            jsMain {
                dependencies {
                    api "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutine_version"
                    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serializer_version"
                    implementation "io.ktor:ktor-client-js:$ktor_version"
                    implementation "io.ktor:ktor-client-logging-js:$ktor_version"
                }
    
            }
            iosMain {
                dependencies {
                    api "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutine_version"
                    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serializer_version"
                    implementation "io.ktor:ktor-client-ios:$ktor_version"
                    implementation "io.ktor:ktor-client-logging-native:$ktor_version"
                    implementation "com.squareup.sqldelight:ios-driver:$sqldelight_version"
                }
    
            }
        }
    
        }}
    I will be very grateful for any ideas
    g
    • 2
    • 1
  • e

    Erik Christensen

    09/11/2019, 12:51 PM
    In Gradle, how can I determine if a particular target is disabled in a multiplatform project? For example, if I'm compiling on Windows, iOS targets won't be available. So I want to detect and avoid configuring an iOS-specific task that calls xcrun in this situation.
    l
    • 2
    • 2
  • g

    gonzooin

    09/11/2019, 2:04 PM
    Hello, compilation is failing and I have no clues why. How can I debug this ?
    Sans titre
    :youtrack: 2
    o
    r
    • 3
    • 2
  • j

    Jurriaan Mous

    09/11/2019, 2:28 PM
    You can disable the DFG phase with
    kotlin {
        macosX64('macos') {
            compilations.all {
                kotlinOptions {
                    freeCompilerArgs += "-Xdisable-phases=Devirtualization,BuildDFG"
                }
            }
        }
    }
    (I had a problem too in an earlier version) To debug you could try the steps I described in another issue I had before: https://github.com/JetBrains/kotlin-native/issues/2864#issuecomment-504641546
    🙏 1
    r
    • 2
    • 5
  • f

    Fail

    09/11/2019, 2:55 PM
    Hi all! How I can use LinkedHashMap from IOS?
    r
    s
    • 3
    • 8
  • a

    Arkadii Ivanov

    09/12/2019, 4:50 PM
    I can't define actual typealas for JVM's AtomicReference: commonMain:
    expect class AtomicReference<T>(value: T)
    jvmMain:
    actual typealias AtomicReference<T> = java.util.concurrent.atomic.AtomicReference<T>
    In Kotlin docs it's stated as possible. Is it so by design?
    k
    • 2
    • 14
  • s

    SrSouza

    09/12/2019, 9:18 PM
    Hey guys, there's a way to not use source set multiplatform style, instead use gradle module style? I'm creating a project that target JVM backend, and JS e JVM clients of the REST from backend , and I want to have a common code between the clients, but not with the backend, but, the backend and the clients has some shared code. The problem is that the kotlin common doesn't have a gradle plugin, someone can help? In the commonMain of the client and backend
    implementation(project(":shared"))
    But I don't know what Gradle plugin I use in the shared module because exist js and jvm plugins but doesn't exist Common
    b
    • 2
    • 4
  • k

    Konstantin Petrukhnov

    09/13/2019, 7:49 AM
    Trying to build kotlin llibrary project LibC that depends on other LibB. MPP, only common code in both projects. Got exception, when trying to build LibC: - Variant 'jvm-api' capability com.company:libb:1.0.2: (full stacktrace in thread)
    a
    • 2
    • 5
  • a

    ansman

    09/14/2019, 2:38 AM
    I’m trying to find an example how to to set up maven publishing for MPP. The offical docs has bits and pieces but it’d like to see the whole setup.
    a
    • 2
    • 2
  • d

    Dico

    09/14/2019, 12:37 PM
    Can I take a multiplatform project with only a jvm target, and change it to a jvm project with 2 jvm sourcesets?
    n
    • 2
    • 5
  • n

    Nicholas Bilyk

    09/14/2019, 2:21 PM
    I've got a multiplatform library, published the normal maven-publish way, but consumers of the library can't see the sources. The sources are published properly, but even attaching the sources manually doesn't work, the IDE just hangs on "Attaching..." Any ideas how to troubleshoot this?
    👀 1
    a
    d
    • 3
    • 2
  • j

    Jan Stoltman

    09/14/2019, 3:21 PM
    Hey guys, is there any equivalent of
    @TestOnly
    or
    @VisibleForTesting
    annotations for K/Mp out there?
    a
    s
    r
    • 4
    • 7
  • a

    ansman

    09/15/2019, 6:32 PM
    Is it possible to use the same code between multiple iOS targets? I don’t really want to redefine my
    actual
    stuff for every iOS target
    d
    l
    • 3
    • 5
Powered by Linen
Title
a

ansman

09/15/2019, 6:32 PM
Is it possible to use the same code between multiple iOS targets? I don’t really want to redefine my
actual
stuff for every iOS target
d

Dominaezzz

09/15/2019, 6:41 PM
You can share a sourceSet between the targets or share a source folder.
a

ansman

09/15/2019, 6:42 PM
Yeah, that’s what I figured. Any examples? Do I just have to do it manually or is there a build in way?
d

Dominaezzz

09/15/2019, 6:43 PM
Manually. Like I've done here https://github.com/Dominaezzz/kgl/blob/804c95042800f5fdb46f2774a15eda1e89f59d1f/kgl-glfw/build.gradle.kts#L77
a

ansman

09/15/2019, 6:44 PM
Right, thanks! It would be nice if there was an alias for iOS that would add all targets
l

louiscad

09/16/2019, 8:33 AM
In this module, I do it to share code between macOS and all iOS targets (3 CPU architectures): https://github.com/LouisCAD/Splitties/tree/aa28eaaa6da877f09f8565ec6c6f4d3825b2d291/modules/preferences All the "magic" that allows this to work well in the IDE is here: https://github.com/LouisCAD/Splitties/blob/aa28eaaa6da877f09f8565ec6c6f4d3825b2d291/buildSrc/src/main/kotlin/config/KotlinSourceSetsConfig.kt#L40 And here's the (Kotlin) script that creates the proper symlinks and directory structure for each target I want to add: https://github.com/LouisCAD/Splitties/blob/aa28eaaa6da877f09f8565ec6c6f4d3825b2d291/scripts/Add-Kotlin-Targets.kts
View count: 4