https://kotlinlang.org logo
Join SlackCommunities
Powered by
# multiplatform
  • s

    Sebastien Leclerc Lavallee

    05/07/2025, 3:39 AM
    Hello everyone! I have an
    expect/actual
    like this:
    Copy code
    expect class PlatformUIComponent
    
    // Android
    actual typealias PlatformUIComponent = FragmentActivity
    // iOS
    actual typealias PlatformUIComponent = UIViewController
    And I have a service in common code that use that class:
    Copy code
    class SomeService {
      fun showView(component: PlatformUIComponent)
    }
    I want to test that function. When I try to call that function in my test, I don't see how to pass an instance of the expected class.
    Copy code
    service.showView(compoment = [???])
    How could I achieve this? Thanks!
    r
    • 2
    • 2
  • a

    Adam Brown

    05/07/2025, 5:54 AM
    Anyone know of a KMP library for loading and running local ML models?
    m
    s
    • 3
    • 4
  • p

    Prakash Irom

    05/07/2025, 6:53 AM
    hi guys, please recommend me a KMP library equivalent to ViewModel for state management?
    r
    a
    t
    • 4
    • 4
  • a

    Andrej Martinák

    05/07/2025, 12:01 PM
    Hello, I would like to get some answers from the JetBrains team working on KMP, hope this is the right place 🙂. I work for a company with a large e-commerce platform on web, Android, and iOS. A year ago, I was hired to work on transforming our mobile native solutions to utilize KMP, so we can share common logic in a single codebase (duh). Both mobile apps are quite complex. While our Android team is enthusiastic about the transition, we're facing significant resistance from our iOS team. I'd like to share their feedback and concerns to understand how JetBrains is addressing these issues in upcoming releases. Developer Experience Issues: • Poor IDE navigation and code completion functionality in Xcode (lots of the code has "ugly" accessors, underscores,
    doInit
    vs
    init
    , etc.) • Needing to rely on third-party libraries (from Touchlab) • General frustration with the development workflow compared to native iOS development Resource Allocation Concerns: • Since the iOS team and their tech lead are not keen on leveraging KMP, nobody is focused on working on the integration of KMP (and making the developer experience better) in the iOS project. The iOS team claims that the implementation and maintenance of KMP takes the focus away from iOS-specific technical tasks. This creates a vicious cycle, where there is no advancement and investment in KMP. • The learning curve for Kotlin diverts resources from platform-specific improvements • Input from Android devs is needed if changes in the KMP library are necessary Long-term Viability Concerns: • The perception that KMP development from JetBrains has been slow over the past 2 years • Focus on Compose Multiplatform, which in our understanding is not as important as focus on good developer experience (and using KMP for the domain layer and not the presentation) • The recent abandonment of Fleet as KMP IDE has raised concerns about JetBrains' commitment • Uncertainty about investing in a technology that might not receive continued support The resistance from iOS developers isn't unique to my company. I've talked to multiple tech leads in large companies in my area and gotten basically the same response - Android devs love the idea, iOS devs are against it. Because of this pattern, leaders have decided not to go "all-in" on KMP (storing only some configurations and networking vs implementing actual business logic). I would like to give the iOS team some garranty, that KMP is the right technology to use, but at this stage, it is quite hard to find it (for example the case studies are few and I'd say obsolete). My questions are: 1. What specific improvements to the iOS developer experience are planned for the next 6-12 months? 2. Following the shift from Fleet to focusing on IntelliJ/Android Studio, what's the roadmap for iOS-specific tooling improvements? Is the focus now on adding Swift support to IDEA Ultimate? 3. When can we expect the first public version of Kotlin-to-Swift export, and what capabilities will it offer initially? 4. Are there plans to simplify the distribution and integration process for iOS applications? E.g. by using Amper or something similar? 5. How is JetBrains addressing the objection that KMP lacks sufficient development momentum? Thanks for any insights you can provide! Would love to see also some perspective from other people in a similar situation as I am 🙂.
    ⬆️ 11
    👍 1
    s
    p
    +6
    • 9
    • 14
  • r

    Rohit

    05/07/2025, 12:24 PM
    Hello I was exploring new ways to export our CMP fat framework to the iOS native app. Currently, we generate the fat framework from the CMP module and integrate it into the main app. Are there any alternative approaches that would avoid a significant size increase on the iOS side?
    ➕ 1
  • s

    Saksham Srivastava

    05/07/2025, 3:25 PM
    Anyone who implemented camera and gallary acccess in CMP ? • Native Implementations with except/actual
    p
    • 2
    • 1
  • c

    coolcat

    05/07/2025, 4:09 PM
    Is it just me or does KMP badly need to get opinionated about how folks integrate it on iOS. At the moment it’s like “it’s up to you, use it directly or use Cocoapods or SPM if you want”. This prevents folks being able to build native integrations easily. Like on Flutter or React Native, there’s no question, everybody uses Cocoapods. So folks can write libs/plugins containing native iOS code, and it all just works. Devs don’t know or care whether the lib they’re importing contains native code. If I wanted to write a native KMP plugin which includes native iOS code, I will need to specify in my installation instructions “you must be using Cocoapods” or similar. This is not ideal. (There is a concern for Flutter and RN that they will find it difficult to move off of Cocoapods because basically ALL plugins are using it. KMP could avoid this by championing SPM early).
    👍 1
    d
    h
    f
    • 4
    • 12
  • m

    Miky Ma

    05/07/2025, 6:26 PM
    Does anyone know how to get the native-cocoapods plugin to use bundler instead of calling
    pod install
    directly? IE it should call
    bundle exec pod install
    or wrap the entire gradle sync in
    bundle exec
    @coolcat Did you find a solution for this? https://kotlinlang.slack.com/archives/C3PQML5NU/p1626901552430600?thread_ts=1626900421.427100&cid=C3PQML5NU
    c
    • 2
    • 2
  • u

    ursus

    05/07/2025, 7:37 PM
    https://zacsweers.github.io/metro/ a new DI library heavy Dagger inspiration, yay!
    🆒 2
    👀 1
  • c

    Carsten Hagemann

    05/08/2025, 9:42 AM
    Hello, my team wants to develop a KMP library as SDK, so that we only have to write the business/API-interacting code once. That's set. But we don't know whether to • Only expose one KMP library for both AND and iOS targets • Or to have an internal (&public AND) KMP library and then an additional "wrapper" library for iOS, so that iOS library consumers don't have to care/know that we are using a KMP library with all that it entails (maybe using SKIE?). What is usually recommended to do in this case?
    h
    r
    +2
    • 5
    • 6
  • v

    Víctor Hernández Bermejo

    05/08/2025, 5:50 PM
    Hi, everyone! I'm using cocoapods in my KMP project and everything worked fine until I updated XCode to the latest version. Now I'm using: - Kotlin: 2.1.0 - macOs: 15.4.1 (24E263) - XCode: 16.3 (16E140) I have followed the guide to integrate cocoapods a couple of times just in case I missed something, and also tried with fresh new projects from the KMP Wizard and from Android Studio but I get the same error in all the cases. Also, I have tried with different versions of Ruby and reinstalling cocoapods. Had someone experience the same issue? I don't know what else I have to check. Thanks in advance for any help
    f
    • 2
    • 2
  • r

    ralf

    05/08/2025, 7:01 PM
    I’m running into this issue and due to adding JS as a target. Adding
    @Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
    solves this problem, but I’d like to do this globally. I tried a compiler argument
    freeCompilerArgs.add("-Xsuppress-warning=RUNTIME_ANNOTATION_NOT_SUPPORTED")
    , but it doesn’t make a difference. Any other suggestion?
    t
    • 2
    • 2
  • h

    Harri Hohteri

    05/09/2025, 6:33 AM
    Hey all, I’ve tried to create a library project which depends on firebase-kotlin-sdk and when building klib
    gradlew :shared:build
    it failed because of
    Copy code
    > Task :shared:linkPodReleaseFrameworkIosArm64 FAILED
    e: Compilation failed: Linking globals named 'kniprot_cocoapods_FirebaseAuth0_FIRUserInfo': symbol multiply defined!
    
     * Source files: 
     * Compiler version: 2.1.21-RC
     * Output kind: FRAMEWORK
    
    e: java.lang.Error: Linking globals named 'kniprot_cocoapods_FirebaseAuth0_FIRUserInfo': symbol multiply defined!
    I got it fixed by defining the following into cocoapods block:
    Copy code
    cocoapods {
            version = "10"
            ios.deploymentTarget = libs.versions.ios.deploymentTarget.get()
            framework {
                baseName = "FirebaseFirestoreXXX"
                isStatic = !enableFirebasePodsForTests
            }
    Ie. added
    isStatic
    whenever not running tests from Android Studio and renaming
    baseName
    to something else than `FirebaseFirestore`as I copied the configuration from the firebase-kotlin-sdk project. This fixed it yesterday but today for whatever reason I’m back to the same error about symbol multiply defined. Any pointers would be helpful. Running tests from Android Studio work fine. I can build an XCFramework fine, but klib fails again. Any help would be appreciated, thanks.
    a
    • 2
    • 2
  • g

    gavin.hu

    05/09/2025, 10:43 AM
    Hey all . KMM Library via Maven: iOS Build Fails with Undefined Symbols Error, CocoaPods Dependencies Not Linked Correctly I am working on a Kotlin Multiplatform Mobile (KMM) project and created a base component library (
    za_kmm_base
    ) that includes a dependency on an Objective-C library (
    za_kmm_oc_lib
    ) via
    cocoapods {}
    configuration:
    Copy code
    kotlin
    Copy code
    cocoapods {
        version = "0.0.2"
        summary = "Za KMM Base Component"
        homepage = "xxxxx"
        ios.deploymentTarget = "12.0"
        pod("za_kmm_oc_lib") {
            version = "0.0.4"
            headers = "ZAKMMRSAUtil.h"
        }
        framework {
            baseName = "za_kmm_base"
            isStatic = true
            transitiveExport = true
        }
    }
    Then, I published
    za_kmm_base
    to a private Maven repository for use in other KMM projects. In another project, I referenced this library via Maven:
    Copy code
    kotlin
    Copy code
    implementation("com.za.group:za_kmm_base:0.0.2")
    However, during the iOS build process, I encountered the following link error:
    Copy code
    php
    Copy code
    Undefined symbols for architecture arm64:
      "_OBJC_CLASS_$_ZAKMMRSAUtil", referenced from:
          in libza_kmm_base.a
    ld: symbol(s) not found for architecture arm64
    🔍 What I Have Tried: • Ensured that • za`_kmm_oc_lib` • is correctly published via CocoaPods and is working properly in the original KMM module. • In the Maven-based project, I • did not configure
    cocoapods {}
    or declare the
    pod("za_kmm_oc_lib")
    again. • Checked Kotlin documentation and found no clear guidance on CocoaPods dependency propagation when KMM libraries are referenced via Maven. ❗ Key Problem Points: > Kotlin Multiplatform does not automatically propagate CocoaPods
    pod()
    dependencies
    when KMM libraries are published via Maven. As a result, symbols defined in Objective-C or Swift code (like
    ZAKMMRSAUtil
    ) cannot be linked in the final project, causing the build to fail. 💡 What I Would Like to Confirm: • Is there an official recommended approach to propagate CocoaPods dependencies for KMM libraries published via Maven? • Do I need to manually declare
    pod("za_kmm_oc_lib")
    in every downstream project to correctly link the dependencies?
    • Is there any plan in Kotlin Multiplatform to support the propagation of CocoaPods dependencies (transitive pod dependencies)?
    a
    • 2
    • 1
  • r

    Robert Munro

    05/09/2025, 11:31 AM
    A shameless plug: I did a little blogs series (7 parts) on some of the more platform dependent issues in building a KMP app. If anyone has any feedback its all very welcome: https://medium.com/@rrmunro/building-deploying-a-simple-kmm-app-part-1-app-icons-8e8b739c7981
    f
    • 2
    • 1
  • m

    martmists

    05/09/2025, 3:58 PM
    What library can I use to load images (from a ByteArray, JPEG/PNG/etc) into some common format? scrimage relies on javax.image which doesn't exist on android unfortunately.
    s
    m
    +2
    • 5
    • 15
  • h

    Hossein Amini

    05/09/2025, 4:08 PM
    Hi all, Is there any way to mock Compose NavHostController in Compose Multiplatform for testing purposes?
    p
    • 2
    • 4
  • m

    Mark

    05/09/2025, 4:22 PM
    I have a multi-module Android app that I’m migrating to KMP (initially with Android and iOS targets). I’m starting with my core library module which has some Android-specific code that needs to be exposed to other modules (Android-only modules and Android code in KMP modules). As I understand it, Android code in a KMP module is not exposed, so I need to create an Android-only module for that. I’m curious what the standard/typical way to group these modules is: 1️⃣ core-android (core/android/), core-shared (core/shared/), or 2️⃣ android-core (android/core), shared-core (shared/core)
    3️⃣ 3
    j
    h
    • 3
    • 5
  • i

    Idris Ocasio

    05/10/2025, 5:56 AM
    Does compose multiplatform have a Time picker dialog I can utilize? I have this view where clicking on choose date will open up a datepicker dialog and then for the from/to sections should open a time picker. Only problem is that Im only seeing 'TimePicker' which does actually expose the time being selected.
    c
    • 2
    • 3
  • f

    François

    05/10/2025, 1:59 PM
    Hi everybody, I have created a discussion on my plugin spmForKmp about the usage of the exported package for Xcode (usefulness, limitation, and beyond). I’m still looking for better developer experiences and going beyond that the CocoaPods plugin does.
  • r

    robercoding

    05/10/2025, 9:49 PM
    Hey I’m having a weird issue when building iOS regarding Kotlin Coroutines coming from Kotlin
    stdlib
    and a ksp task. I cannot find information out there, it seems to be a very unique error. Error in 🧵 Does anyone know what would cause a build in Xcode Cloud to fail only there? Building the app and executing archive locally works fine 🤔
    a
    • 2
    • 7
  • m

    Mark

    05/11/2025, 12:43 PM
    Is it possible to declare string resources in a KMP module and access them as
    @StringRes Int
    in a Android library module that has the KMP module as a dependency. I thought this might do it, but no luck so far:
    Copy code
    experimentalProperties["android.experimental.kmp.enableAndroidResources"] = true
    This is pretty important for incremental migration. Perhaps I could dynamically include the
    strings.xml
    of the KMP module in the resources of the Android module?
    • 1
    • 1
  • y

    Yaroslav Shuliak

    05/11/2025, 12:45 PM
    I'd like to investigate performance issues on kotlin native (iOS), are there any tools like CPU profiling, method call tracing, etc for kotlin native on iOS? I'm a bit surprised that it took 0.4s on debug android build to run my code vs 3.8s on iOS simulator... I assume there might be a lot of allocations that degrade performance but overall it's difficult to investigate using only logs
  • b

    buszi0809

    05/11/2025, 4:05 PM
    Hi, I'm trying to migrate to use the multiplatform version of the Android Library plugin, and have encountered an issue with configuring the JVM version. At the first attempt I've configured it this way:
    Copy code
    androidLibrary {
        compilations.configureEach {
            compilerOptions.configure {
                jvmTarget.set(JVM_TARGET)
            }
        }
    }
    but then I've received a deprecation message that I should use
    compileTaskProvider
    instead. But the issue is that when I migrate to it:
    Copy code
    androidLibrary {
        compilations.configureEach {
            compileTaskProvider.configure {
                compilerOptions {
                    jvmTarget.set(JVM_TARGET)
                }
            }
        }
    }
    the
    jvmTarget
    is unresolved in here. Has anyone found a solution for this? I'm using Kotlin version
    2.1.20
    . My opinion is that the root cause of that is because the type of
    compileTaskProvider
    is too ambigous:
    Copy code
    val compileTaskProvider: TaskProvider<out KotlinCompilationTask<*>>
    t
    • 2
    • 2
  • j

    jamescodingnow

    05/12/2025, 12:19 AM
    📱 Add Firebase to Kotlin Multiplatform + Compose? My latest Medium article covers how to add Firebase to your project step-by-step. 🔥 Then, next article will about Remote Config! ⌨️ 👀 Read it here: https://medium.com/advanced-kotlin-multiplatform-kmp/add-firebase-to-kotlin-multiplatform-compose-multiplatform-3663c6a8f19c
    👀 5
    c
    j
    +3
    • 6
    • 6
  • c

    carbaj0

    05/12/2025, 8:52 AM
    I can´t build any iOS app because 🧵 Kotlin 2.2.0-Beta2 and compose multiplatform 1.8.0 Thread in Slack Conversation
  • s

    Slackbot

    05/12/2025, 1:03 PM
    This message was deleted.
    t
    y
    • 3
    • 2
  • r

    Robert

    05/12/2025, 3:41 PM
    Q: I created my project with some wizard (https://kmp.jetbrains.com/) then committed the file to GitHub. But it did not commit the .idea folder and therefore my debug/run config is no longer available when opening a fresh copy in my Android Studio IDE. Can I recreate it with some command, or do I have to recreate it manually/run the wizard again?
    d
    • 2
    • 1
  • d

    Dhruv Singh

    05/12/2025, 6:20 PM
    Hey everyone! 👋 We’re currently piloting Kotlin Multiplatform (KMM) (KMP) in our architecture and had a few questions as we explore its integration in a large modular setup: 1. We’re moving from Moshi to Kotlinx Serialization in the shared KMM KMP layer. Has anyone recently done this in their existing architecture? Would love to hear about any learnings or common issues faced during this transition. 2. We’re planning to create a shared KMM KMP library that will eventually support 200+ modules. Has anyone implemented something at this scale? Curious to know how you managed shared dependencies, modular boundaries, and coordination between Android and iOS teams for fixes. 3. Other areas we’re actively exploring: ◦ Monitoring app size, build time, and startup performance with KMM KMP in place ◦ Handling *Swift interop*—especially around Objective-C exposure, exception handling, and interface/protocol differences ◦ Combine framework interoperability with Ktor networking We’ve already gone through this solid write-up If anyone here is working on a similar setup—especially in *large-scale Indian consumer-facing apps*—would be great to hear about your experiences and challenges in production. Thanks in advance! 🙏
    🤖 2
    c
    • 2
    • 2
  • t

    Thierry Kh

    05/13/2025, 2:09 AM
    Not sure where to ask this but in my project using Voyager, I tried simulating a backpress in the AppActivity via a callback. I have a list detail pane scaffold nested in a navigation suite scaffold. Both navigators stacks are empty when the app is opened via a deeplink. So pop does nothing and is useless. I'm implementing deep links, and when a link is invalid, a dialog notifies the user. If they dismiss it, we navigate back to the previous app. I used a composition local to trigger a backpress from my home screen. It worked. But I noticed that when I open the app again, the navigation becomes buggy. Some events are not registered anymore. Particularly the ones supposed to clear the detail panes states. The screens keep reopening when I want to close them (I have a mechanism that automatically reopen tabs detail pane when navigating away then back to a tab). It looks like the VM is not VM'ing anymore or smth, idk why. When I close a screen it triggers an event to close the screen and normally clears a state to avoid reloading the screen. The logs show that events are emitted to update the secondary screens states but they don't seem to be collected. The previous state is replayed (screen reopening). This happens only when I do a backpress programmatically or a finish() then reopen the app. The navigation being broken because of this, for now I decided to remove the automatic backpress logic but I'd like to understand why navigating back out of the app, or finishing the activity break the navigation.