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

    basher

    06/26/2019, 7:00 PM
    Does anyone know how to check the machine host in groovy gradle?
    • 1
    • 2
  • s

    sunbreak

    06/27/2019, 4:28 AM
    With kotlin/MPP 1.3.31
    fun foo(block: (Int) -> Unit) { ... }
    in Kotlin would be
    func foo(block: (KotlinInt) -> KotlinUnit)
    in Swfit, and
    foo(Function1<Integer, Unit> block)
    in Java. Both require KotlinUnit.Init() (or Unit.INSTANCE) After upgraded to 1.3.40, it can be
    func foo(block: (KotlinInt) -> Void)
    in Swift, without the KotlinUnit.Init(). Would it possible to omit the Unit.INSTANCE in Java?
    g
    • 2
    • 1
  • n

    Nikolai

    06/27/2019, 12:06 PM
    Hi, everyone Is it possible to use cocoapods in multiplatform projects? And if yes can someone provide an example? I saw some examples added some lines to build.gradle and managed to build it. But I can’t import it in iOS part of common module.
    k
    • 2
    • 4
  • j

    JoakimForslund

    06/27/2019, 2:33 PM
    Anyone know how to either create a working shadowJar/jar package task configuration for groovy with the generated
    JS Client and JVM Server
    project for 1.3.40 ? (more specificly the jvm server)
    • 1
    • 2
  • a

    adiba

    06/27/2019, 4:56 PM
    Anyone know why IntelliJ IDEA creates mobile projects with android and shared code coupled together in the same module? https://discuss.kotlinlang.org/t/structuring-modular-android-kotlin-multiplatform-projects-intellij-idea/13238
    b
    l
    • 3
    • 2
  • l

    Liang Song

    06/27/2019, 10:37 PM
    Hi I am testing generics support for Objective-C/Swift in
    1.3.40
    , I have two interfaces
    interface CompletionHandler<T> {
        fun onCompletion(result: T)
        fun onException(exception: Exception)
    }
    interface TestGenerics {
        fun test(completionHandler: CompletionHandler<String>)
    }
    the signature of
    TestGenerics
    in the generated Objective-C header is
    __attribute__((swift_name("TestGenerics")))
    @protocol TMDTestGenerics
    @required
    - (void)testCompletionHandler:(id<TMDCompletionHandler>)completionHandler __attribute__((swift_name("test(completionHandler:)")));
    @end;
    Looks like it is still not supported
    b
    r
    • 3
    • 4
  • c

    coletz

    06/28/2019, 10:13 AM
    kotlin{
      jvm("desktop"){
        compilations.main.kotlinOptions.jvmTarget = "1.8"
      }
    }
    It is still using java 11, so javafx is not working :( Anyone know how can I force the compiler to use java 8?
    r
    a
    • 3
    • 5
  • v

    Vojtech Hrdina

    06/28/2019, 12:12 PM
    Hi, anyone could help? 1. https://github.com/JetBrains/kotlin-native/issues/3094 - Warning will be ignored by default in 1.3.41 - How it will be fixed? Do we still need add -Xcc -Wno-swift-name-attribute in build settings? 2. Any idea how to add more than one multitiplatform library in iOS project? ex: I have multiplatform library libA, libB, libC. iOS appA has only libA, appB should have libA, libB, libC - but it is limited by https://github.com/JetBrains/kotlin-native/issues/2423. Is it possible build something like xcode-framework-core, xcode-framework-libA, xcode-framework-libB, xcode-framework-libC and import core+libA, lib… to iOS app? Or only one workaround is write gradle task to compile multiple source sets into one xcode-framwork?
    s
    • 2
    • 1
  • f

    Fudge

    06/29/2019, 3:01 PM
    I'm having a helluva time trying to publish a multiplatform library to bintray. The problem I'm stuck on is this error when syncing gradle;
    Could not get unknown property 'java' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.
    This is my build.gradle: https://pastebin.com/vxanr3UU I have found people doing it in many other ways, but I haven't found a solution that works from start to finish. How do I work around this error?
    • 1
    • 2
  • e

    egorand

    06/29/2019, 8:37 PM
    I’m trying to setup a multiplatform test project that at the moment contains code only in
    src/commonTest
    and
    src/jvmTest
    . The CI build fails with the following message:
    > Task :wire-tests:linkDebugTestLinuxX64 FAILED
    e: Could not find "/home/travis/build/square/wire/wire-tests/build/classes/kotlin/linuxX64/main/wire-tests.klib" in [/home/travis/build/square/wire, /home/travis/.konan/klib, /home/travis/.konan/kotlin-native-linux-1.3/klib/common, /home/travis/.konan/kotlin-native-linux-1.3/klib/platform/linux_x64].
    Pretty sure it’s a project misconfiguration problem, but I can’t figure it out, any ideas? The Gradle build can be found here: https://github.com/square/wire/blob/egorand/190629/kotlin-test-protos-to-common/wire-tests/build.gradle
    a
    • 2
    • 2
  • l

    louiscad

    06/30/2019, 10:29 PM
    Publishing a multi-modules (40+) multiplatform library to bintray using the
    maven-publish
    Gradle plugin be-like:
    BUILD SUCCESSFUL in 41m 15s
    1866 actionable tasks: 1247 executed, 432 from cache, 187 up-to-date
    Before, I was using bintray gradle plugin, (plus didn't support Kotlin/Native in 3 modules that now support iOS and macOS) and the compilation + upload was taking 2-3 minutes on a equally fast internet connection. Now I'm looking for setting up a free CI for open source projects that would do it on command for me, off my laptop, so I can keep working on the codebase while publishing a version (that might still be useful after the state of
    maven-publish
    and Kotlin/Native compilation speed improves). Recommandations are welcome!
    p
    b
    +3
    • 6
    • 13
  • s

    serebit

    07/01/2019, 5:26 AM
    I have an expect class as such:
    internal expect class WeakReference<T>(reference: T) {
        fun get(): T?
    }
    I want to define an
    actual typealias
    on
    kotlin.native.ref.WeakReference
    for the linuxx64 source set. When I declare it as such, the compiler complains that `visibility is different`:
    internal actual typealias WeakReference<T> = kotlin.native.ref.WeakReference<T>
    When I remove
    internal
    , the compiler still complains that
    visibility is different
    . Should I report this?
    s
    • 2
    • 4
  • e

    EnricCamarero

    07/01/2019, 11:11 AM
    1.3.40 users! 🙋‍♂️ Can you use generics for swift when compiling your .frameworks using the cocoapods integration? Compiling without it works great but it doesn’t when integrating with cocoapods. Any ideas? 🤷‍♂️
    s
    • 2
    • 3
  • a

    adiba

    07/01/2019, 1:56 PM
    Is anyone currently hosting projects in separate repositories e.g (iOS project in one repo and Android & shared MPP in a separate repository)?
    k
    • 2
    • 20
  • s

    spierce7

    07/01/2019, 5:11 PM
    I'm converting a large android project that uses several
    kotlin-multiplatform-<platform>
    plugins to use the
    multiplatform
    plugin. I'm several weeks into this, and have the app building, but for some reason the IDE is showing some imports as unable to resolve (again, the app can build, and I've added the dependencies properly to the corresponding gradle files). The issue seems to be around the android multiplatform projects importing jvm multiplatform projects, and then the android project complains that it can't find jvm files. Has anyone seen something like this? I can repro this in my project with AndroidStudio, IntelliJ, and AndroidStudio 3.5 with the upgraded beta05 plugin as well.
    r
    a
    • 3
    • 14
  • d

    Dominaezzz

    07/01/2019, 10:59 PM
    Composite builds? Is it known to not work? Any work-arounds? (
    publishToMavenLocal
    is a last resort.)
    ❓ 1
    d
    a
    n
    • 4
    • 12
  • v

    vsazel

    07/02/2019, 11:54 AM
    Hi, Is there possibility to configure gradle to run tests in debug mode from IntelliJ for Node.js Javascript with multiplatform plugin? jvmTest works ok. But jsNodeTest and jsBrowserTest not. It never stops for the breakpoint.
    • 1
    • 2
  • a

    Arkadii Ivanov

    07/02/2019, 10:15 PM
    Hello, I'm trying to write a multiplatform module with testing utils which supposed to be shared across the project. I have added
    test-common
    dependency to
    commonMain
    source set but compilation fails due to
    kotlin.test
    package cannot be resolved. IDEA does not show any errors. What maight be the problem?
    a
    • 2
    • 2
  • d

    Denis Shurygin

    07/03/2019, 12:12 PM
    Does anybody published MPP library on JCenter as a single package? Currently I have a library for Logs in Bintray maven repository https://bintray.com/beta/#/pocketbyte/maven/hydra-log?tab=files And it works fine if I add following repository "https://dl.bintray.com/pocketbyte/maven/" in
    build.gradle
    But as I understand, each target is independent package and should be added into JCenter independently. What is the right way to do it?
    m
    s
    t
    • 4
    • 5
  • r

    rharter

    07/03/2019, 8:13 PM
    I've got an OpenGL based Kotlin-mpp library that I've created, with targets for both
    androidNativeArm32
    and
    androidNativeArm64
    , both deployed to by local maven repo. How can I set up my Android app to depend on that? Is there a way to use the maven dependency and either generate or write a jni wrapper?
    d
    s
    • 3
    • 5
  • k

    Kirill Zhukov

    07/03/2019, 11:56 PM
    Very new to Kotlin multiplatform. When adding MPP dependency do I need to specify platform (e.g. “jvm”) in the dependency or is Gradle smart enough to recognize that I have a jvm project thus I will need jvm artifact of that MPP dependency?
    k
    • 2
    • 2
  • t

    thana

    07/04/2019, 7:26 AM
    can my e.g.
    jsTest
    depend on the
    commonTest
    set of a different module? i'd like to provide some common test files for several modules...
    a
    r
    • 3
    • 5
  • u

    4ntoine

    07/04/2019, 7:39 AM
    Hey, guys. Is there multiplatform
    lock
    or
    synchronized
    in Kotlin? https://stackoverflow.com/questions/56882860/is-there-multiplatform-lock-on-kotlin
    t
    e
    +5
    • 8
    • 34
  • s

    spierce7

    07/04/2019, 7:03 PM
    Is there a way to add multiple directories to a source set with the
    multiplatform
    plugin?
    r
    • 2
    • 2
  • m

    Malachi de Ælfweald

    07/05/2019, 2:23 PM
    I am trying to put together a poc using cinterop inside mpp to create an android aar. Using androidNativeArm64 as the target, I was able to get cinterop to generate the klib files and deploy them to mavenLocal. I haven’t had much luck getting them consumed though. None of the packages in the auto-generated code are found. I tried using the includeBuild and specifying the dependencies on both the pom and the klib. Is there a code snippet somewhere that shows how to properly consume the .klib dependencies inside and Android library project?
    h
    • 2
    • 5
  • a

    alex.hart

    07/05/2019, 5:44 PM
    Does anyone have documentation about wrapping and modifying Swift
    structs
    from multiplatform code?
    k
    • 2
    • 6
  • s

    spierce7

    07/06/2019, 2:54 AM
    Are there any examples anyone can point me to of releasing a Kotlin multiplatform library to jcenter?
    s
    k
    f
    • 4
    • 114
  • d

    Darmaheev

    07/07/2019, 2:59 AM
    Hello everyone, can anyone help me? When I try to add a transitive dependency to Ios target, I get the error
    "Could not find method export () for arguments [<myLibrari>] on object of type org.jetbrains.kotlin.gradle.dsl.KotlinNativeBinaryContainer"
    This library in the sourceSet is declared as api. Gradle version 4.10.3. kotlin-multiplatform 1.3.41. My build.gradle -
    kotlin {
        targets {
            final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
                                  ? presets.iosArm64 : presets.iosX64
    
            fromPreset(iOSTarget, 'ios') {
                binaries {
                    export "myLybrary"
                    framework('framework-ios')
                }
            }
        }
        sourceSets {
            commonMain {
                dependencies {
                    implementation kotlin('stdlib-common')
                    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializer_version"
                }
            }
            iosMain {
                dependencies {
                    implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serializer_version"
                    api "myLybrary"
                }
    
            }
        }
    }
    b
    l
    • 3
    • 3
  • m

    Matej Drobnič

    07/07/2019, 7:24 PM
    How to enable
    UseExperimental
    annotation in multiplatform project? I tried
    kotlin {
        targets.all {
            compilations.all {
                kotlinOptions {
                    freeCompilerArgs += "-Xuse-experimental=kotlin.Experimental"
                }
            }
        }
    }
    and IntelliJ still warns about missing compiler argument
    r
    l
    • 3
    • 10
  • c

    Casey Brooks

    07/08/2019, 4:25 PM
    How can I make a pure Kotlin/JVM Gradle module depend on the
    jvmMain
    output from another multiplatform module? Normally I’d use
    implementation(project(":lib"))
    , but it doesn’t seem to be working when
    :lib
    is a multiplatform project
    r
    • 2
    • 5
Powered by Linen
Title
c

Casey Brooks

07/08/2019, 4:25 PM
How can I make a pure Kotlin/JVM Gradle module depend on the
jvmMain
output from another multiplatform module? Normally I’d use
implementation(project(":lib"))
, but it doesn’t seem to be working when
:lib
is a multiplatform project
I’m using the Kotlin DSL by the way
r

russhwolf

07/08/2019, 4:51 PM
I think that should work. Make sure you have
enableFeaturePreview("GRADLE_METADATA")
in
settings.gradle.kts
c

Casey Brooks

07/09/2019, 6:43 PM
After playing around with this a bit more, it seems like that does indeed work for Gradle, but Intellij doesn’t seem to like it.
r

russhwolf

07/09/2019, 7:26 PM
There are lots of cases for more complex project structures where things look weird in Intellij but work fine from gradle. If you have a minimal example I recommend filing a bug at kotl.in/issue but unfortunately some of this is just to be expected since we’re still in the experimental/early-adopter phase with all of this.
But I’m pretty sure a vanilla project with a single multiplatform module and a single JVM consumer module works fine in IDEA right now. I’m guessing your actual project is probably more complicated than this.
View count: 5