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

    vishal G

    06/28/2022, 9:31 AM
    How to use compose pagination with moko mvvm
  • v

    vishal G

    06/28/2022, 9:32 AM
    Using livedata
  • c

    Chris NL

    06/28/2022, 3:52 PM
    I'm trying to understand what the best approach is to create a multiplaform app that runs on Android phone, Android Wear, iPhone and iWatch with a shared library. In my post from yesterday I was using Cocoapods for the shared library, but this gives me such a big headache, maybe I have to use XCFramework? I just tried to get it to work with an empty (new) Kotlin Multiplatform App project from Android Studio to get the "Hello, <<platform>>" demo running with the "Regular framework". It runs on the iPhone, but after adding the watchOS target in XCode, the problems start. I have uploaded the demo project to github: https://github.com/Chris-NL/Demo Building and running for iPhone works fine. Building for WatchOS works fine, but give me a warning: "linking against a dylib which is not safe for use in application extensions". When trying to run on the iWatch gives xCode gives me an installation error: "A signed resource has been added, modified, or deleted." I tried adding isStatic = true to build.gradle.kts, although that does remove the warning for watchOS, it results in installation errors on the iPhone. iMac (Retina 5K, 27-inch, Late 2015 with an 3,3 GHz Quad-Core Intel Core i5 running MacOS Montery 12.4) Android Studio Chipmunk xCode 13.4.1 all the latest plugins installed Anyone a clue on how to get this poperly to work?
    c
    • 2
    • 1
  • l

    Luan Pereira

    06/28/2022, 11:23 PM
    I'm getting this error after calling a fun that returns a Promise:
    Unhandled Runtime Error TypeError: hidden._get_entries__31877249_iz8n5_k$ is not a function
    browser request is responding 200 Any idea? The fun in js target:
    fun initialize (formId: String, hidden: Map<String, String>): Promise<InitializationResult> = GlobalScope.promise{ internalForm.initialize(formId, hidden)}
    t
    • 2
    • 15
  • b

    Benjamin Deroche

    06/29/2022, 10:04 AM
    I have a KMM project that target Android, iOS and desktop JVM. Is there any way to easily share a small part of code between Android and JVM? It's just 20 lines of code, it doesn't look enough to create a new separate module just for this 😔
    v
    r
    r
    • 4
    • 8
  • f

    François-Xavier Beuvry

    06/29/2022, 1:38 PM
    Hello 👋 I’m trying to develop a small POC to prove KMP is a good candidate to have our own shared library between Android and iOS. This library have to embed
    WebRTC
    compiled for each architecture. This is the first time for me with KMP, I am not sure about the good way to deal with my current issue. I built my shared library in KMP with embedded WebRTC for Android. It works like a charm. On iOS, I tried to create a
    .xcFramework
    with embedded WebRTC
    xcFramework
    . I can compile my iOS application with my own framework, and I can access to my library (like
    WebRtcKt.initialize()
    ). But… I can’t access to WebRTC directly (like
    RTCMTLVideoView
    ). 🤔 I tried several things, like transitive import, etc. but I didn’t find the good recipe ! 😂 If someone has any idea how to do that… 🙏
  • d

    Daria Voronina [JB]

    06/29/2022, 3:50 PM
    💬Results of the Kotlin Multiplatform Survey Q3-Q4 2021💬 Did you know that almost half (48%) of Kotlin Multiplatform developers use Android Studio with the Multiplatform Mobile Plugin installed? We asked backend, frontend, mobile, and full-stack developers about their experience with Kotlin Multiplatform. Check out the key highlights of our Q3–Q4 2021 user survey in this blog post!
    :kotlin-intensifies-purple: 6
    :android-eyes: 1
  • t

    Trey

    06/29/2022, 8:21 PM
    Does anybody know of a sample project that uses AudioQueues for playing audio on iOS that was written using Kotlin in the iosMain portion of the shared module? I haven't seen any samples that do non-trivial iOS api calls with Kotlin yet.
  • j

    Jeff Lockhart

    06/29/2022, 10:18 PM
    Is it possible to achieve
    @BeforeClass
    behavior in Android/iOS common tests? kotlin.test has the annotation for Kotlin/Native, as does Junit for JVM. My naive attempt to typealias the two doesn't work on the JVM side.
    e
    b
    • 3
    • 30
  • c

    clark

    06/30/2022, 2:33 AM
    Has anyone been able to get Cocoapods dependencies working on an M1 mac? From what I understand
    cocoapods-generate
    is needed to make it work, which requires a certain version of
    cocoapods
    which requires Ruby
    2.6.0
    which does not run on M1 macs.
    j
    • 2
    • 2
  • c

    clark

    06/30/2022, 2:34 AM
    I'm running into this issue trying to add
    firebase-kotlin-sdk
    and consume it in an iOS app. Getting the following error when I try to build iOS:
    ld: framework not found FirebaseAuth
    So I tried installing it via pods before running into all the pods issues mentioned above. Any workarounds would be greatly appreciated!
  • b

    Bao Le Duc

    06/30/2022, 7:14 AM
    I’m using iOS cocoapods dependencies in my shared library.
    pod("AFNetworking") {
                version = "~> 4.0.1"
            }
            pod("AgoraRtcEngine_iOS")
    both libraries are available from https://cocoapods.org/ and working with another (standalone) iOS project. However,
    cinteropAgoraRtcEngine_iOSIosArm64
    was failed and I got
    Exception in thread "main" java.lang.Error: /var/folders/3j/8k6z66l50dq_d1sjfxl8cphh0000gn/T/10429521223665112771.m:1:9: fatal error: module 'AgoraRtcEngine_iOS' not found
    If I removed
    pod("AgoraRtcEngine_iOS")
    , it worked fine and I can
    import cocoapods.AFNetworking.*
    in iOS source-set Kotlin code. Any help are welcome!
    r
    k
    j
    • 4
    • 13
  • a

    Aditya Kurkure

    06/30/2022, 12:58 PM
    I have a kmm module (
    B
    ) that depends on another kmm module (
    A
    ). However I also need to call
    A
    from my iOS app. I have a singleton in
    A
    that I initialise in my app and whose methods I call in
    B
    . Currently I get a not initialised exception in module B even though I have initialised my singleton in the app. Any Idea how I can fix this? Both the modules are in a single project and I am specifying their path in my podfile.
    m
    a
    • 3
    • 8
  • j

    Javier

    06/30/2022, 1:00 PM
    Can linuxMips32 and linuxMipsel32 be published with a macOS machine?
    s
    • 2
    • 1
  • t

    Trey

    06/30/2022, 3:16 PM
    I have an existing project that we are hoping to switch to use KMP. We have a lot of complex swift code that we would like to include in the shared component. However, rewriting all of that Swift code would be time consuming. The Swift code does stuff like play buffered audio as it is streamed across the network. Is there a trick to reusing that Swift code easily? How have others migrated Swift code into a KMP world?
    l
    • 2
    • 2
  • t

    timkranen

    06/30/2022, 3:38 PM
    Hey! Bit of an in depth question, but I’m super interested in hearing what your approach is on this problem: I’m currently sharing all of my logic from the ViewModel upwards in KMM. So I’m using an actual/expect construct for the VM, where the android VM uses the jetpack viewmodel, and iOS uses a ‘default’ class. Then I’m using Koin for dependency injection, which works great on Android since there is a simple
    viewModel
    scope. But I’m running into problems on iOS with regards to the lifecycle.. Currently my VM is marked as a singleton for iOS, however there are a couple of problems that arise: • Initially I thought it would be a good idea to cancel the scope in the viewModel on viewDisappeared, but when I’m navigating back to that same screen Koin will provide the same VM with a cancelled coroutine scope, so that breaks stuff.. • Changing the viewModel to be a factory solves this problem, but then I can’t retain state across screen navigation, which isn’t the end of the world and I can make it work, but it seems like it’s limiting? It also introduces the problem of somehow having to manually save state like scroll positions What are your approaches to the lifecycle of viewmodels on iOS? When do you cancel the scope? Does the VM retain state across navigation?
    c
    m
    • 3
    • 12
  • r

    ribesg

    07/01/2022, 2:41 PM
    Wouldn’t it be nice to be able to have the
    AndroidManifest.xml
    file of a “pure” Kotlin Multiplatform library generated or hidden or something? I have multiple modules which are pure Kotlin and only have code in
    commonMain
    sourceSet but they all have to have an
    androidMain
    folder with an almost empty
    AndroidManifest.xml
    file. Anybody else finding that annoying or I am just nitpicking?
    ➕ 4
    h
    d
    +3
    • 6
    • 12
  • k

    kenkyee

    07/01/2022, 2:45 PM
    like this? https://github.com/GradleUp/auto-manifest
  • d

    Davide Giuseppe Farella

    07/01/2022, 5:07 PM
    Good morning guys, I’m resurrecting a 2yo Multiplatform Project + Android compose. I’m now on: • Kotlin 1.7 • AGP 7.2.1 • Compose 1.2.0-rc03 • Compose compiler 1.2.0 I’ve got some Multiplatform modules and surprisingly I didn’t need to change the Gradle setup
    // something/build.gradle.kts
    plugins {
        kotlin("multiplatform")
    }
    
    kotlin {
        jvm()
    
        sourceSets {
            val commonMain by getting {
                dependencies {
                    implementation("blablabla")
    Then I got an Android module
    // client/android/build.gradle.kts
    plugins {
        id("com.android.application")
        kotlin("android")
    }
    
    dependencies {
        implementation(project(":something")
    My Gradle Sync succeeds, but in the Android module, all the dependencies from other modules are unresolved ( screen ) The IDE suggests me to add the dependency to the classpath, but the action adds a weird line, without any progress:
    implementation(project(mapOf("path" to ":client")))
    a
    l
    • 3
    • 4
  • j

    Jeff Lockhart

    07/02/2022, 4:20 AM
    I've found that the IDE is throwing a bunch of errors for my androidTest source set, where it doesn't see any of my commonTest code. This includes `expect class`es and other types defined there. The tests compile and run without issue, but the IDE errors and lack of code completion are unhelpful. Is this a known issue or is anyone aware of a resolution? Android Studio Chipmunk 2021.2.1 Patch 1 AGP 7.2.1 Kotlin 1.7.0
    a
    p
    +3
    • 6
    • 21
  • r

    robstoll

    07/02/2022, 8:26 PM
    I have tests in commonTest and would like to debug them in KotlinJs (nodejs). For whatever reasons, the break-points do not kick in. Any Ideas?
    b
    • 2
    • 2
  • g

    Gillian Buijs

    07/03/2022, 6:51 AM
    I've been working on using KMM in Flutter. The library, Klutter, is now available and I recently published a tutorial about it. I'm personally very excited about using KMM with Flutter! Would love to get some feedback because I've been working on it on my own. If you have ideas, improvements, etc, don't hesitate to message me! I would really appreciate it. https://medium.com/@jjgbuijs/flutter-battery-app-made-with-klutter-74d47002efb1
    🙌 6
    s
    a
    • 3
    • 4
  • k

    kotlinforandroid

    07/03/2022, 2:30 PM
    I have a hard time deciding how to manage my state in KMM. My database layer exposes flows. And I usually handle logic inside of Android ViewModels. Is there a goto approach in KMM?
    s
    m
    +4
    • 7
    • 8
  • j

    Jeff Lockhart

    07/04/2022, 7:28 AM
    Contrary to this blog post (which was very helpful and insightful), I'm finding that src/commonTest/resources are not available to Android unit or instrumented tests. Is this expected behavior? Even adding
    kotlin {
      sourceSets {
        val androidTest by getting {
          resources.srcDir("src/commonTest/resources")
          ...
    doesn't copy the resources from the common location for Android tests. Is there a good way to avoid duplicating these resource folders between source sets (hopefully other than a manual symlink)?
    w
    r
    • 3
    • 7
  • r

    Rachel Carandang

    07/05/2022, 2:08 PM
    Update on KMM not working on arm64 simulator on M1 Macbook: I previously posted about having issues with KMM framework file generated by the Cocoapods gradle plugin working with the arm64 simulator target on iOS. After suggestions in this thread, I stopped using the cocoapods plugin and switched to XCFramework which included the arm64 simulator target. This did not work on the simulator. Instead, I was only able to get simulator with my KMM project working if I opened Xcode with Rosetta to run the x64 simulator target. If anyone has any suggestions on how to get the arm64 simulator target to work, let me know.
    h
    t
    +2
    • 5
    • 11
  • u

    uli

    07/06/2022, 9:55 AM
    I am seeing KTIJ-19344 with latest stable and EAP AppCode, both with the latest KMM plugin. Has the fix not arrived on AppCode? I can not test on AS as I have x64 only dependencies in the App need a x64 ios simulator on Apple M1 which seems not supported with AS.
    • 1
    • 1
  • d

    Devendra Kumar Gaur

    07/06/2022, 12:52 PM
    I am working on image processing with voize-gmbh/pytorch-lite-multiplatform But the dependency is not installed in the Kmm project. if we comment out the iosSimulatorArm64() then library is installed successfully. But in case of Xcode when we running the iosApp project the having linker issues. And if the iosSimulatorArm64() is uncommented again then we are not able to installed the library. And One more thing how to convert the Bitmap32 to UIIMage and vice-versa in KMM. and also In case of Android we are able to convert the Korim Bitmap into Android Bitmap. but how to convert android bitmap to Korim Bitmap. Thanks in advance.
  • a

    Austin Pederson

    07/06/2022, 10:52 PM
    Is there anywhere that I can go for more information about KMM releases? I am specifically curious at this time about the
    native.cocoapods
    plugin for the gradle file. I noticed a difference in the output of my podspec and I can't seem to find any information on this change on the web
  • c

    Christoph Wiesner

    07/07/2022, 12:00 PM
    Hi, we wanted to adopt KMM and I had my iOS colleague doing a spike by re-writing a lib of iOS in KMM. i turned out that there is a blocker for us to use and certain flaws: • no support for
    Codable
    in iOS: currently nearly all models of our native iOS app implement that protocol and therefore shared KMM models cannot be used in those models (unless you manually write (de)serialization for that shared objects - which is a blocker for us) - seems like a known issue - but i wonder why there is not much more noise around that. other issues he mentioned: • Operator overloads do not translate to Swift ◦ e.g. cannot overload operators such as
    +
    ,
    -
    ,
    <
    etc. (required for conformance to
    Comparable
    for example) • Cannot take advantage of other protocol conformances, e.g. inheriting from the protocol
    Sequence
    gives a huge amount of functionality such as
    map
    ,
    flatMap
    ,
    forEach
    etc. • Integers are all represented as
    Int32
    in Swift - annoying to do conversions to a regular
    Int
    everywhere • Cannot create non-final classes, meaning we cannot implement any class as
    Codable
    or
    Strideable
    (needed to allow us to loops over calendar dates in a calendar date range) • Unable to have “Swifty” function names as it’s not possible to remove parameter names, and parameter labels have to be the same as the parameter names. i.e. we cannot have a function like
    func date(in timeZone: TimeZone) -> Date
    would be great if someone can confirm this limitations or provide guidance on how to overcome those.
    👍 2
    s
    t
    a
    • 4
    • 4
  • a

    andylamax

    07/07/2022, 1:29 PM
    Is any one here using gradle composite build as dependency substitutors for kotlin multiplatform projects with success? Any workaround is welcomed
    b
    m
    t
    • 4
    • 5
Powered by Linen
Title
a

andylamax

07/07/2022, 1:29 PM
Is any one here using gradle composite build as dependency substitutors for kotlin multiplatform projects with success? Any workaround is welcomed
b

Big Chungus

07/07/2022, 1:51 PM
KMP composite builds are not supported by intellij yet (works just fine on cmdline though)
👍 1
A workaround would be a good old publishToMavenLocal
m

Marco Righini

07/07/2022, 8:17 PM
We are using it, it's building from the ide too but there are red imports and unresolved references with kotlin 1.6.21 (@Sebastian Sellmair [JB] can add additional details probably). I'm interested if there's an eta for this to be supported
t

Tijl

07/08/2022, 7:20 AM
track/vote this issue: https://youtrack.jetbrains.com/issue/KT-52172
a

andylamax

07/08/2022, 9:26 AM
With help from another channel I managed to get it compiling. IDE is still showing red imports. @Big Chungus publishing to maven local is a no no coz these tools need to be consumed by others internally. We have an internal maven repo
View count: 3