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

    Jan

    11/25/2021, 8:44 PM
    I have two targets and probably add more for native, tho ktor doesn't support that thing I want to use on native thats why I wanted to create seperate source sets for them but can I somehow make JS and JVM depend on the same implementation (so expected classes)?
    • 1
    • 2
  • m

    Moritz Post

    11/26/2021, 9:41 AM
    Hello. Using the KMM plugin version 0.3 in AndroidStudio Chipmunk Canary 5 on Windows with the installed kotlin plugin of 1.6.0-rc2 allows to create a new kmm project now. While i can launch the freshly created Android app, the IDE marks the shared code in the
    androidApp
    module as "can not find". Is there something not working just yet?
    a
    • 2
    • 4
  • m

    MarkRS

    11/26/2021, 11:15 AM
    Is it hoping for too much to want to see Kotlin classes from the common module in the variables window in the XCode debugger?
    t
    • 2
    • 8
  • a

    Alexander Suraphel

    11/26/2021, 12:36 PM
    hi all, i’m going to start a multiplatform project. Targeting Android and Desktop now, ios shortly after. Is https://kotlinlang.org/docs/kmm-setup.html up to date?
    m
    m
    c
    • 4
    • 17
  • s

    Skolson5903

    11/26/2021, 5:50 PM
    Does anyone know the Intellij Idea youtrack issue URL or number for the problem with the IDE showing a false syntax error on any usage of an actual fun that doesn't specify a parameter with a default value in the expect definition? I've got a number of these and would like to start watching the issue that must be out there, but my searches are not finding it. To clarify, here's an example of the defect with a constructor, same thing happens on expect/actual fun:
    expect class Anything(
        arg1: String,
        arg2: String = ""
    ) { ... }
    
    actual class Anything(
        arg1: String,
        arg2: String
    ) { ... }
    
    val x = Anything("x")
    Every usage like this compiles fine in gradle and runs fine, but the IDE wrongly shows the assignment statement as a syntax error. The IDE inspection is going by the actual syntax which is not allowed to duplicate the default value defined in the expect. I have enough of these that the IDE defect is making me never want to use arguments with default values in an expect class again :-)
    c
    • 2
    • 1
  • x

    xxfast

    11/27/2021, 12:39 AM
    Hi all, pretty new to ios kmm development. I’ve recently migrated my project from old
    packForXCode
    to
    embedAndSignAppleFrameworkForXcode
    , and ever since all the kotlin sources in my swift fails will
    error: ambiguous use of 'myKotlinClass'
    Am no longer able to jump to definitions of any of my kotlin objects - and pretty sure something went wrong with the new linkages. Is there a way to debug this? using kotlin
    1.5.31
    • 1
    • 1
  • o

    oianmol

    11/27/2021, 5:26 AM
    Is there support for gRPC in kotlin multiplatform ? anyone ?
    👀 1
    m
    • 2
    • 2
  • e

    edwinRNDR

    11/27/2021, 3:44 PM
    how do I fix missing javadoc jar errors on maven central?
    p
    r
    e
    • 4
    • 13
  • d

    darkmoon_uk

    11/28/2021, 12:30 PM
    Do we have any support for specifying Java Modules (Jigsaw) in a KMP JVM target? I'm compiling against Java 11 and need to use an AWT class from my desktop (JVM) target and it's not on the classpath due to being separated from the main SDK as a module.
    👀 3
    m
    • 2
    • 2
  • r

    Rahul Rawat

    11/28/2021, 7:19 PM
    Can anyone help out with the following error I am getting in sqldelight for nativeMain desktop containing all three(mac, linux and mingw) as targets? Following is my declaration in source sets for nativeMain
    val nativeMain by getting {
                dependencies {
                    implementation("io.ktor:ktor-client-curl:$ktorVersion")
                    implementation("com.squareup.sqldelight:native-driver:$sqlDelightVersion")
                }
            }
    • 1
    • 1
  • h

    Hannes

    11/28/2021, 8:24 PM
    Hey folks, I am trying to use
    native.cocoa
    plugin as described here: https://kotlinlang.org/docs/native-cocoapods.html#install-the-cocoapods-dependency-manager-and-plugin I’m just trying the code snipped from the docs to use
    AFNetworking
    inside iOSMain (as described in the docs).
    kotlin {
       ...
        cocoapods {
            summary = "Some description for the Shared Module"
            homepage = "Link to the Shared Module homepage"
            ios.deploymentTarget = "14.1"
            frameworkName = "sharedClient"
            podfile = project.file("../iosClient/Podfile")
    
            pod("AFNetworking") {
                version = "~> 4.0.1"
            }
        }
        ...
    }
    The problem I am facing right now is that
    cinteropAFNetworkingIos
    fails:
    > Task 😒haredClient:cinteropAFNetworkingIos Exception in thread “main” java.lang.Error: /var/folders/n9/5pkml05d7mn3xzdyty8cx5380000gn/T/3707914287112298431.m1️⃣9: fatal error: could not build module ‘AFNetworking’
    at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:192)
    at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:68)
    at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:531)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:268)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76)
    at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
    at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38)
    at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)
    > Task 😒haredClient:cinteropAFNetworkingIos FAILED
    I think it is more of a cocoa pods issue on my local machine, but I don’t really know how cocoa pods works exactly under the hood. I think cocoa pods did not download AFNetworking. (In a plain iOS / xcode project (not kotlin multiplatform app) I have used successfully cocoa pods, so I think it is fair to assume the required cocoa pods gems are installed on my machine.) Could anyone please point me in the right direction?
    j
    v
    • 3
    • 6
  • s

    Stefan Oltmann

    11/29/2021, 9:19 AM
    My method takes a
    val requestSystemPhotoLibraryAccessPermission: suspend () -> SystemPhotoLibraryAccessLevel
    suspend lambda. What is the correct way to call this in Swift?
    requestSystemPhotoLibraryAccessPermission: {}
    gives me an error as soon as I add the suspend keyword:
    Argument type '() -> ()' does not conform to expected type 'KotlinSuspendFunction0'
    What do I need to change? I don't understand that from the docs. 🙈
    ✅ 1
    h
    g
    • 3
    • 9
  • s

    Stefan Oltmann

    11/29/2021, 10:12 AM
    Can I create a Flow in Swift code if I have a parameter like
    val requestSystemPhotoLibraryAccessPermissionFlow: () -> Flow<SystemPhotoLibraryAccessLevel>
    ? Or is just collection of a Flow in iOS code possible?
    m
    • 2
    • 1
  • m

    MarkRS

    11/29/2021, 12:24 PM
    Accessing iOS files in KMM? I thought I'd seen comment (here) that Kotlin file access works, but I can't find any reference to it. Otherwise I'm trying to use NSFileManager and currently struggling with error returns from file access functions. Can anyone point me in the right direction (please)?
    k
    • 2
    • 2
  • a

    Anton Afanasev

    11/29/2021, 3:11 PM
    Hi, I am trying to understand how to avoid the InvalidMutabiltyException in following scenario: I have a ReconnectionManager that I want to be able to try and execute the
    reconnectFun
    . The idea is to trigger that function after some delay (which is incrementing from one attempt to another). The
    reconnectFun
    is passed from the parent class that is responsible for network error listening. I understand that my problem is that I mutate the
    attempts
    from with in the other thread, as well I call the
    reconnectFun
    but what is the proper way of doing something similar?
    internal class ReconnectionManager {
        private var attempts = 0
        private val dispatcher = CoroutineScope(Dispatchers.Main + SupervisorJob())
    
        fun reconnect(reconnectFun: () -> Unit) {
            dispatcher.launch {
                delay(attempts * 1000)
                withContext(Dispatchers.Default) {
                    attempts++
                    reconnectFun()
                }
            }
        }
    }
    s
    k
    • 3
    • 6
  • l

    Lukasz Kalnik

    11/29/2021, 3:32 PM
    What is the current recommendation for having shared viewmodel logic between Android and iOS? Is https://github.com/icerockdev/moko-mvvm a good idea? I'm interested in having automatic coroutine cancelation when viewmodel gets destroyed and easy Jetpack Compose/SwiftUI integration.
    s
    k
    +2
    • 5
    • 47
  • a

    Adam Brown

    11/29/2021, 8:48 PM
    I'm giving the new KMM plugin a try, I'm on windows, and if I create a project with cocoa pods support, it fails to even sync the gradle script on windows, because
    pod
    can't be found. I even went through and installed cocoa pods on windows and it can't find it. Does anyone have an experience with KMM w\ cocoa pods support on windows?
    k
    • 2
    • 2
  • a

    Adam Brown

    11/29/2021, 9:32 PM
    Problem #2: I created a new project (without cocoa pods support), but with Kotlin 1.6.0 and latest KMM plugin, and it seems confused about the common source sets. when using the Android view in the project browser, all of the modules under shared actually point to the
    androidMain
    source set
    r
    • 2
    • 2
  • a

    Adam Brown

    11/29/2021, 11:36 PM
    So I'm looking at the various KMM Architecture libs out there, is there any clear preference emerging yet on what most people use for defining their screens and navigation and such?
    s
    l
    • 3
    • 2
  • m

    Matthias Geisler

    11/30/2021, 11:34 AM
    Hey lovely people, I am currently playing with some tools to generate source code...unfortunately they of course do generate Java... The question, which pops up now, is there a converter which can be integrated with Gradle to convert Java to Kotlin?
    t
    l
    • 3
    • 6
  • j

    Jim

    12/01/2021, 12:05 AM
    Has anyone here seen 
    warning: Cannot find annotation method 'xi()' in type 'Metadata'
     style errors when using a kmp-jvm library from a java project? I kinda thought using the 
    java
     and 
    java-library
     plugins would make things "just work"
    r
    • 2
    • 2
  • m

    Michal Klimczak

    12/01/2021, 8:53 AM
    I don't really understand how to read / write files in okio 3 multiplatform (specifically on ios). All examples show how to do it using
    FileSystem.SYSTEM
    which is only available on `jvm` . It's like everything is there when you have
    FileHandle
    or
    Sink
    , but the first step is vague. Any hints?
    m
    s
    • 3
    • 18
  • p

    ptsiogas

    12/01/2021, 9:25 AM
    Hi guys, I have noticed that when we produce a XCFramework for our shared code, the
    ios-arm64
    architecture folder is ~4 times larger than the
    ios-x86_64-simulator
    . For example for a really small project the
    ios-arm64
    folder is ~30MB and for a large project it’s ~75MB. Hint: we have tried to produce the XCFramework with both the native plugin and the multiplatform-swiftpackage plugin but we got the same size. Have you noticed anything similar? Is there a way to reduce its size?
    k
    • 2
    • 21
  • l

    Lukasz Kalnik

    12/01/2021, 1:51 PM
    When I change the shared module, what Gradle task can I use to rebuild the shared Framework for XCode to notice the changes?
    s
    • 2
    • 9
  • a

    Adam Brown

    12/01/2021, 8:41 PM
    anyone here use Koin for multiplatform projects? I'm doing some KMM prototyping and am woundering if I can use Koin to inject in my Swift code
    w
    • 2
    • 9
  • a

    Alexandre Brown

    12/02/2021, 2:28 AM
    Does someone have experience with sub modules with kotlin multiplatform ? (Eg : multiple modules in commonMain) Having a rough time setting it up with Intellij IDE. Thanks
    w
    • 2
    • 3
  • p

    Pavel Repkin

    12/02/2021, 8:27 AM
    Hi, guys! KMM is wonderful. Unfortunately, I’ve stumbled to a new obstacle. We need to unzip files on iOS. I have added ZIPFoundation library as CocoaPods dependency to KMM project. ZIPFoundation implements zip archive extraction as an extension to FileManager. Like this.
    let fileManager = FileManager()
    fileManager.unzipItem(at: sourceURL, to: destinationURL)
    As far as I know, there is no access in Kotlin to Swift’s FileManager. Instead we have an access to NSFileManager only. So I’m not able to unzip because FileManager.unzipItem() cannot be called from Kotlin. Is there a workaround for this problem?
    b
    w
    k
    • 4
    • 5
  • m

    Michael

    12/02/2021, 4:11 PM
    Hello, everyone. Just wondering what people do debug:
    Task 'embedAndSignAppleFrameworkForXcode' not found in project ':shared'.
    Adding
    --debug
    or
    --stacktrace
    to the task doesn't really help. I usually have to just randomly change things till it starts working. Is there a way to know the specific reason for the task failing. I know for a fact that it's generated when run from
    XCode
    but that's about it. Any debugging tips? 😅 Thanks in advance. Also. Is the source code available on Github? 🤔
    s
    t
    +2
    • 5
    • 20
  • a

    Alexandre Brown

    12/02/2021, 5:26 PM
    How can we create sub modules like we can easily do on JVM (not multiplatform) projects? For instance, in the photo the module is recognized as a directory even though I have the include in my
    settings.gradle.kts
    Thanks
    b
    • 2
    • 59
  • a

    Anamika Trivedi

    12/02/2021, 8:10 PM
    Hi All! I'm about to start creating my first kmm project from scratch. Can you recommend me any nice tutorials, github projects etc to start with?
    a
    a
    • 3
    • 5
Powered by Linen
Title
a

Anamika Trivedi

12/02/2021, 8:10 PM
Hi All! I'm about to start creating my first kmm project from scratch. Can you recommend me any nice tutorials, github projects etc to start with?
a

Alejandro Rios

12/02/2021, 8:27 PM
https://kotlinlang.org/docs/multiplatform.html#tutorials
https://kotlinlang.org/docs/multiplatform.html#sample-projects
a

Anamika Trivedi

12/02/2021, 9:40 PM
Thanks
a

Alexandre Brown

12/03/2021, 12:32 AM
Here's a few from @Big Chungus that are super helpful! https://github.com/mpetuska/klip https://github.com/mpetuska/kmdc https://github.com/mpetuska/kon https://github.com/mpetuska/kamp https://github.com/mpetuska/template-kmp-library
:thank-you: 1
a

Anamika Trivedi

12/03/2021, 2:08 PM
I will be focussing on mobile mostly.
View count: 13