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

    atsushieno

    09/01/2021, 8:51 AM
    Is there any known Multiplatform way to "relativize" file path from another path like
    java.nio.file.Path.relativize()
    ? As far as I checked, okio Path/FileSystem and ktor Url don't seem to provide such a feature.
    j
    • 2
    • 1
  • t

    tylerwilson

    09/01/2021, 3:29 PM
    Trying to use the new XCFramework support in 1.5.30. When trying to add watchos target, I get the following. Anybody else see this?
    Compilation failed: The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ command returned non-zero exit code: 1.
    output:
    clang (LLVM option parsing): for the --fast-isel option: may only occur zero or one times!
    clang (LLVM option parsing): for the --global-isel option: may only occur zero or one times!
    
     * Source files: 
     * Compiler version info: Konan: 1.5.30 / Kotlin: 1.5.30
     * Output kind: FRAMEWORK
    t
    • 2
    • 6
  • s

    Sebastian

    09/01/2021, 4:49 PM
    Not sure if this belongs into #javascript or here:
    l
    • 2
    • 1
  • c

    coolcat

    09/01/2021, 7:46 PM
    My iOS KMM build fails on my Jenkins server, when I run it on a node which is running multiple concurrent builds. The default separator character for workspace folders is
    @
    . So your build may run at: 
    /Users/jenkins/workspace/MyKMMProject
    , and a concurrent build runs at
    /Users/jenkins/workspace/MyKMMProject@2
    . In this scenario I get the error:
    > Task :shared:compileKotlinIos FAILED
    e: Could not find "/Users/jenkins/workspace/MyKMMProject" in [/Users/jenkins/workspace/MyKMMProject@2/Pods, /Users/jenkins/.konan/klib, /Users/jenkins/.konan/kotlin-native-prebuilt-macos-1.5.21/klib/common, /Users/jenkins/.konan/kotlin-native-prebuilt-macos-1.5.21/klib/platform/ios_arm64]
    I think this is due to the
    @
    because there is no reference in any environment variable to the path name without the separator. I suspect something is wrongly parsing the file path and tripping up on the
    @
    but I don’t know where this would be, and therefore where to raise this bug. Does anybody have any suggestions for troubleshooting this (other than reconfiguring the separator Jenkins character).
    a
    • 2
    • 2
  • l

    Lars Toft Jacobsen

    09/02/2021, 9:10 AM
    message has been deleted
    l
    • 2
    • 9
  • t

    Tim Malseed

    09/02/2021, 10:36 PM
    I've built a native library, using JNI, which resulted in a
    mylib.a
    . Now, I'd like to include that library in a KMP jvm desktop application. I know I need to call
    System.loadLibrary("myLib")
    , but what I'm not sure about, is where the
    mylib.a
    file needs to reside. Does it need to be extracted into
    .so
    files first? How can I make the static native lib available to java?
    e
    • 2
    • 4
  • j

    jw

    09/03/2021, 2:15 AM
    with hmpp can i define an expect class in commonMain, redefine it as an expect in intermediateMain with more functions, and then actual it in platformMain?
    r
    s
    l
    • 4
    • 11
  • d

    Dazai

    09/03/2021, 3:37 AM
    how do I write this class with expect/actual?
    d
    l
    • 3
    • 2
  • s

    Slackbot

    09/03/2021, 12:58 PM
    This message was deleted.
    o
    r
    • 3
    • 6
  • a

    Anton Afanasev

    09/03/2021, 2:16 PM
    Hi everyone! I was wondering how you implement listeners in KMM ( in particular K\N)? To avoid retain cycles? Do you use expect/actual and wrap listener with WeakReference on K\N? For example:
    // Multiplatform
    class KmmLibrary(private val listener: Listener) {
    
        fun doSomething() {
            listener.notifyResult("All good!")
        }
    
        interface Listener {
            fun notifyResult(result: String)
        }
    }
    
    // Native
    struct ContentView: View {
        @State private var message: String = ""
        private let kmmLibrary: KmmLibrary
    
        init() {
            self.kmmLibrary = KmmLibrary(listener: NativeListener())
        }
    
        class NativeListener: Listener {
            func notifyResult(result: String) {
                print(result)
            }
        }
    }
    Does not this code created retain cycle on iOS (Native)? Should I somehow wrap it with WeakReference using expect/actual mechanism or are there any other common practices?
    a
    • 2
    • 2
  • s

    spierce7

    09/03/2021, 7:21 PM
    Does anyone know how to get code completion working when importing a cocoapods module? It works in the iosX64Main source set, but doesn’t work in any of the other source sets.
    👀 1
    a
    v
    • 3
    • 4
  • n

    nalaka

    09/04/2021, 4:03 AM
    Is there a way to consume a Kotlin Multiplatform library from a Flutter app? Is this relevant? https://flutter.dev/docs/development/platform-integration/platforxm-channels In earlier discussion @Sam mentioned dart:ffi is not very practical for this: https://kotlinlang.slack.com/archives/C3SGXARS6/p1585001422338600 Use case: Say, • There is a
    foo-types
    and
    foo-biz
    Kotlin Multiplatform libraries that has the "data types" and "sharable business logic" • This is consumed from Ktor backend services with Kotlin/JVM • This is consumed from React webapp as a Node.js library with Kotlin/JS (IR) • Need a way to consume this from a Flutter app Hoping someone has already done this. 🙂 Thx.
    😭 1
    k
    p
    • 3
    • 2
  • e

    edwinRNDR

    09/04/2021, 10:44 AM
    Not sure if this is the right place (as I suspect this is more of an Intellij IDEA issue) but I have a lot of problems with IJ reporting errors like:
    Cannot access class 'org.openrndr.draw.FontImageMap'. Check your module classpath for missing or conflicting dependencies
    f
    d
    • 3
    • 10
  • u

    ursus

    09/04/2021, 5:34 PM
    Hi, all multiplatform example I read are where the both ios and android apps in the same gradle build/project and in the same git repo I'd like a monorepo for both platforms in our case but its simply not the case and won't be for some time. (each platform has its own git repo) We decided we wanted to wet out feet with kotlin multiplatform by sharing 1 module. So, what would be the best course of action? 1. Create 3rd git repo and extract the module as a standalone gradle project with all the multiplatform settings as necesary 2. somehow build binaries for both platforms, and deploy them to maven/cocoapods. 3. each platform consumes the prebuilt binary for their platform, as any other 3rd party library Sounds doable?
    👀 2
    a
    u
    +2
    • 5
    • 20
  • t

    Tomasz Krakowiak

    09/06/2021, 2:10 AM
    Strange think in stdlib-common I found, looks like a bug. Details in comments. (
    setOf(singleElement)
    )
    l
    k
    m
    • 4
    • 8
  • n

    Nikolay Kasyanov

    09/06/2021, 9:12 AM
    If I have a value class, can I modify its underlying value in constructor somehow? Here’s what I mean, more or less (this won’t compile though):
    value class ValueClass(val impl: SomeOtherType) {
        init {
            this.impl = impl.somePreprocessingReturningAnotherImpl()
        }
    }
    b
    p
    • 3
    • 8
  • d

    Didier Villevalois

    09/06/2021, 6:34 PM
    Hi all! Does the
    *.api
    files generated in a multiplatform project show all the public APIs of the library?
    m
    • 2
    • 4
  • j

    Jamie Craane

    09/07/2021, 12:29 PM
    In our app we use the packForXCode task to copy the framework to the correct folders. In this task we also copy some extra resources (assets.car) to the framework using doLast like in the following example:
    doLast {
    copy {
    from("${project.rootDir}/android-app/src/commonMain/resources/ios")
    into("${targetDir}/shared.framework")
    }
    }
    What is the best approach to do this with the embedAndSignAppleFrameworkForXcode task? I was trying something like this (in the build script of the shared module):
    tasks {
    named("embedAndSignAppleFrameworkForXcode") {
    doLast {
    val targetDir = findProperty("configuration.build.dir")
    // Copy resources here
    }
    }
    }
    But the message I get is: Task with name ‘embedAndSignAppleFrameworkForXcode’ not found in project ‘:shared’. I updated to Kotlin 1.5.30. The task is correctly ran from Xcode.
    h
    k
    l
    • 4
    • 6
  • c

    Chris Fillmore

    09/07/2021, 3:57 PM
    Hi folks, I have some Kotlin code I’d like to bundle into an SDK and consume in a React Native app. It seems, from searching this channel, that people may be doing this, but when I google the topic the results tend to be KMM vs RN type articles. Whereas I want to just produce a platform-agnostic SDK for handling messaging with some services. Is anyone using Kotlin code with React Native somehow? Thanks!
    b
    k
    a
    • 4
    • 7
  • p

    Peter Hsu

    09/07/2021, 7:23 PM
    has anyone successfully built the new native memory management model? I've updated kotlin versions, but now end up with build errors around variants
    j
    • 2
    • 8
  • n

    Nikolay Kasyanov

    09/08/2021, 10:57 AM
    Hey folks, has this approach to sharing tests and dependencies between different iOS platforms never worked?
    iosArm64Test {
                dependsOn iosX64Test
            }
    I mean, it works for
    ...Main
    source sets, but apparently not for test ones. Yes it’s a bit 🦕 but moving to HMPP takes time. I only found out it wasn’t working by adding
    iosSimulatorArm64
    slice and a similar dependsOn construct for it.
    s
    • 2
    • 5
  • k

    kavi

    09/08/2021, 11:45 AM
    Hi! I’m just getting started with KMM and but rather than building an Android app and iOS app, I’d like to build an Android and iOS SDK, with a shared Kotlin library/framework that each depends on. However the Android Studio/IntelliJ template seems to only be setup for outputting apps as the final products rather than SDKs. I’m comfortable with android and gradle, and I’ve managed to change the android app to a library, but am much more unfamiliar with iOS and so was after a bit of direction please 🙏🏾 My plan is to just create a new xcode workspace with a new framework target, and copy the pod file and build script steps from the KMM generated iOS app template. Does this seem correct? I am a bit concerned about missing some steps to get it all linked together properly… Are there any Github repos or docs that would help me with this? Also it would be great if in future the wizard could ask whether you wanted to produce an app or library
    s
    • 2
    • 1
  • h

    hfhbd

    09/08/2021, 3:48 PM
    Hey, does the KMM plugin only support iOS simulator and no real iOS device?
    v
    e
    • 3
    • 5
  • s

    spierce7

    09/08/2021, 7:42 PM
    Does anyone know how to get rid of this error when working with cocoapod?
    [!] Automatically assigning platform `iOS` with version `13.5` on target `App-iOS` because no platform was specified. Please specify a platform for this target in your Podfile. See `<https://guides.cocoapods.org/syntax/podfile.html#platform>`.
    I can’t figure out how to specify the platform in gradle.
    r
    • 2
    • 7
  • j

    Jan

    09/08/2021, 11:34 PM
    IntelliJ just reloaded my project and removed all modules ? Now no class etc. gets recognized. How can I fix that?
    b
    c
    +2
    • 5
    • 14
  • x

    xiaobailong24

    09/09/2021, 12:56 PM
    Hello, I have a Java base library and a same objective-C base library. And there is a
    abstract class JavaAbsClass
    in java library, and a
    class ObjcAbsClass
    in objc library. So
    except abstract class CommonAbsClass
    is defined in kmm commonMain module, and
    actual typealias CommonAbsClass = JavaAbsClass
    that's not a problem in kmm jvmMain module. But in kmm iosMain module, not only
    actual typealias CommonAbsClass = ObjcAbsClass`
    is unsupported, but also
    actual typealias CommonAbsClass = ObjcAbsClassWrapper
    abstract class ObjcAbsClassWrapper:ObjcAbsClass()
    will get a compiler error with
    Non-final Kotlin subclasses of Objective-C classes are not yet supported
    . So how should I do to interop abstract class with both jvm and objc library? Thanks very much!
    b
    • 2
    • 27
  • a

    Andre Servidoni

    09/09/2021, 1:17 PM
    Hello all, I need help, I’m trying to build my iOS app on xcode, did all the configurations from https://blog.jetbrains.com/kotlin/2021/07/multiplatform-gradle-plugin-improved-for-connecting-kmm-modules/ but always receiving this error:
    Task 'embedAndSignAppleFrameworkForXcode' not found in project ':mobile_shared'.
    what I need to do? I followed all the steps.
    j
    r
    m
    • 4
    • 7
  • a

    Alfred Lopez

    09/09/2021, 1:44 PM
    Hello All, I have a project that I’m working on behind a corporate firewall, so I only have access to our Artifactory instance. This project targets nodejs(), and our build machines already have node and yarn installed. I tried the following to prevent the build from trying to download/install node/yarn, but it doesn’t seem to have any effect:
    rootProject.plugins.withType(NodeJsRootPlugin::class) {
        var nodeJsRootExt = rootProject.the<NodeJsRootExtension>()
        nodeJsRootExt.download = false
        nodeJsRootExt.nodeVersion = "16.15.4"
    }
    
    rootProject.plugins.withType(YarnPlugin::class) {
        var gsmlYarnRootExt = rootProject.the<YarnRootExtension>()
        gsmlYarnRootExt.download = false
        gsmlYarnRootExt.version = "1.22.11"
    }
    For some reason, the build “sees” the assigned version numbers, but it ignores the download = false. Also, I’m using plugin version 1.5.20, and the YarnRootExtension class clearly has “download” as a field, but IntelliJ says otherwise and when I Cmd+Click to go to the definition of the class, the property is not there, which means to me that gradle is not pulling in the latest for some reason. Do any of you have any insight to this? Thanks!
    t
    i
    • 3
    • 10
  • m

    Marc Plano-Lesay

    09/10/2021, 10:27 AM
    What are people using these days in terms of logging? I have some Flogger on JVM and Timber on Android, I'm looking to replace both by a common library for shared modules. I tried Napier earlier but it doesn't seem to be achieving what I'm looking for - a log placed on the common JVM module didn't end up using the configured Android logger on an Android app...
    j
    k
    +2
    • 5
    • 7
  • k

    kevindmoore

    09/10/2021, 3:48 PM
    I've been trying KMP for awhile now and the Android/ios side is not bad. I'm trying to add desktop and shared compose code and gradle is killing me. Every time I fix 1 error, another one comes up. Google search doesn't help because this is too new. Compose compiler keeps complaining about a version of compose that I am not using. I've tried upgrading to Kotlin 1.5.30 to see if that would help. No luck
    s
    l
    d
    • 4
    • 6
Powered by Linen
Title
k

kevindmoore

09/10/2021, 3:48 PM
I've been trying KMP for awhile now and the Android/ios side is not bad. I'm trying to add desktop and shared compose code and gradle is killing me. Every time I fix 1 error, another one comes up. Google search doesn't help because this is too new. Compose compiler keeps complaining about a version of compose that I am not using. I've tried upgrading to Kotlin 1.5.30 to see if that would help. No luck
s

Sam

09/10/2021, 5:31 PM
I don’t know if desktop Compose is different but Jetpack Compose needs Kotlin 1.5.21 for now.
☝️ 1
k

kevindmoore

09/10/2021, 6:52 PM
I believe the version I am using is compatible and will handle lower versions as well
l

louiscad

09/10/2021, 7:11 PM
You can use the alpha version of the compose compiler that works with 1.5.30
k

kevindmoore

09/10/2021, 9:24 PM
That's what I am trying to do. I believe I'm using the latest alpha
d

darkmoon_uk

09/11/2021, 1:34 AM
While I don't have the time to walk through it right now @kevindmoore, I can confirm that sharing code between Android and Desktop via KMP is fully working for me, with the latest Compose/MP artifacts. Configuring this is definitely a learning curve but sometimes it helps just to hear from someone that is possible!
k

kevindmoore

09/11/2021, 6:14 PM
I finally got it working. I started from a known state and slowly built up using another project as an example. Using 1.5.21 seems to be working. Lots of fixes had to be done
👍 1
View count: 11