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

    kevinskrei

    12/14/2022, 4:18 PM
    Has anyone resolved the
    The code signature version is no longer supported.
    when installing on a real iOS device? The app runs on the simulator fine and I've followed all of the steps here: https://kotlinlang.org/docs/multiplatform-mobile-understand-project-structure.html#ios-application I'm just sharing a KMM module locally using
    embedAndSignAppleFrameworkForXcode
    in the build phases and when I remove that build phase it will install fine on a real device. I see there is a way to share the code via cocoapods and using the
    path
    to set it. But I'm trying to avoid using cocoapods on iOS.
  • s

    Sean Keane

    12/14/2022, 4:42 PM
    Hi All! I've got a KMM question you might have experienced before... Basically we are building a KMM Lib that depends on a Pod (it's tensorflow) but when we import the exported SwiftPackage to the Demo app it doesn't seem to be including the pod in the dependencies. Do you know if there is a way of exporting the pod with the XCFramework file? I'm kinda stumped and can't see anything on the channels. This is what I have in the Gradle build file
    iosArm64 {
        binaries {
            framework {
                isStatic = true
                transitiveExport = true
            }
        }
    }
    
    cocoapods {
        summary = Metadata.IOS.summary
        homepage = Metadata.IOS.homepage
        version = Metadata.IOS.sdkVersion
        ios.deploymentTarget = Metadata.IOS.deploymentTarget
        framework {
            baseName = Metadata.IOS.frameworkBaseName
            isStatic = true
            transitiveExport = true
        }
        pod("TensorFlowLiteTaskVision")
    }
    Basically when we use it we get this error in XCode
    Undefined symbol: _OBJC_CLASS_$_GMLImage
    which is part of the Tensorflow pod...
    a
    • 2
    • 2
  • p

    Patrik Andersson

    12/14/2022, 8:05 PM
    Hello! Is varargs unsupported in kmm?
    m
    j
    • 3
    • 3
  • d

    Daniel

    12/14/2022, 8:35 PM
    Best way to call 2 suspended Kotlin methods on swiftUI
  • d

    Daniel

    12/14/2022, 8:37 PM
    Currently I am calling them this way, but it creates somehow 2 different sessions whenever call the second method:
    func checkIfUser()
      {
        Task{
              do{
                    try await self.repo.getUserProfile().watch() {items in//first method
                        self.myUser = items as! UserInfo
               
                     repo.insertFCMWhenLogin(token: myFCMToken!){error in//second method
                                                                 }
    k
    • 2
    • 2
  • s

    saket

    12/14/2022, 10:09 PM
    As someone who was using AppCode to build multiplatform macOS projects, I'm very sad that I'll have to go back to Xcode 😔. https://blog.jetbrains.com/appcode/2022/12/appcode-2022-3-release-and-end-of-sales-and-support/
    i
    c
    +7
    • 10
    • 16
  • z

    Zeeshan Syed

    12/15/2022, 9:36 AM
    Hey Everyone. This is Zeeshan Syed. I'm an Android App Developer working with Genfare SPX. We have a requirement to unify the Point of Sale features. Our goal is to club a web, Windows application and Android app (each one has many similar functionality). These 3 platforms' main functionality is to read and write smart cards using a USB card encoder (we have more devices like a customer pole display, credit card swiping machine, etc). Since we have 3 different platforms to handle individually, we had to do a lot of effort making changes in each platform. That's why we want to build a unified Kotlin Multi-platform project. I have no clear way of planning and I don't know whether it is possible to do or not. Because, each platform (Windows and Android) heavily depends on platform specific code as we have to access peripheral devices connected to USB. If you have any suggestions on how to achieve this or if you want more info, please ask. Your suggestions will help us tremendously.
    m
    • 2
    • 1
  • c

    cybr0ugh

    12/15/2022, 2:37 PM
    KMM folks, Is there a KMM lib which can be use to perform cryptographic ops similar to what java.security does? Usecase is to generate key pairs using algorithms like EC
    l
    v
    • 3
    • 3
  • s

    Stanislav Radchenko

    12/15/2022, 3:18 PM
    Hi all. I am doing a project in Jetpack Compose Multiplatform. I need to implement google sign in on Android and iOS. Are there any libraries, any ideas how I can organize expect/actual interface for each platform?
    k
    l
    • 3
    • 5
  • e

    Erwin Pandawa5

    12/15/2022, 3:24 PM
    message has been deleted
    v
    • 2
    • 1
  • t

    Trey

    12/15/2022, 4:48 PM
    I'm not sure how to determine what is wrong based on this error message. Any advice on how to proceed with debugging?
    Untitled.txt
  • m

    mbonnin

    12/15/2022, 10:54 PM
    https://youtrack.jetbrains.com/issue/KT-55513/Promote-Kotlin-Multiplatform-Mobile-to-Stable
    j
    h
    e
    • 4
    • 9
  • y

    ynsok

    12/16/2022, 9:05 AM
    Hello everyone, I’m trying to make common Firebase Analytics and Crashlytics implementations for android and IOS. But I’m just facing a problem adding Firebase dependencies, I’m getting the error:
    Project already has a CocoaPods dependency with the name FirebaseCrashlytics
    . Any idea how to solve this?
    kotlin {
        android()
        ios()
    
        cocoapods {
            summary = "This module contains implementation of analytics and crashlytics"
            ios.deploymentTarget = "15.0"
            version = "1.10.2"
            framework {
                baseName = "monitoring"
                   pod("FirebaseCrashlytics")
                // pod("FirebaseAnalytics")
            }
        }
    }
    a
    • 2
    • 2
  • a

    Arkadii Ivanov

    12/16/2022, 12:02 PM
    I have updated my
    parcelize-darwin
    compiler plugin, that I created a couple of years ago. And published the first version. https://twitter.com/arkann1985/status/1603702344658685953 Basically it adds Parcelable and Parcelize support for all Darwin targets. Experimental. Together with expect/actual it makes it possible to use Parcelize in commonMain.
  • e

    Edgars Malahovskis

    12/16/2022, 12:07 PM
    Hi everyone, is there any good kmm library for QR code scanning?
    b
    • 2
    • 1
  • m

    MarkRS

    12/16/2022, 12:52 PM
    Can I typeAlias a class with expect and then add extension functions to it in the respective platform portions? I've tried it with the bare "expect class" statement in common and then adding extension functions in the platform code, but I'm then finding the rest of the code doesn't find the extension functions. It doesn't seem to matter if I extend the typeAlias or the original class. Is it doable?
    m
    • 2
    • 2
  • f

    Fernando

    12/16/2022, 2:55 PM
    Hi there, I have created a KMP library implementing ktor, but when I install this library in a project personal, I get the following message:
    Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/client/engine/cio/CIO
    , can you help me please?
    g
    • 2
    • 1
  • j

    jean

    12/16/2022, 9:31 PM
    For some reason, the “ios” target disappeared from my unit test gutter icon menus. Any idea why that would happen? I can still run
    gradle iosX64Test
    and it works correctly though
  • j

    jessel

    12/16/2022, 9:41 PM
    Out of curiosity, why is
    MPP
    used as the shorthand for multiplatform?
    d
    • 2
    • 1
  • i

    ian.shaun.thomas

    12/16/2022, 9:42 PM
    multiplatform programming
  • d

    Davide Giuseppe Farella

    12/17/2022, 12:54 AM
    Hello people, is there a way to have special characters, in tests, in a KMP module with an Android variant? I have a module with various Unit Tests with backticks names ``like this`` , and after adding
    android()
    variant, I cannot build because of
    com.android.tools.r8.internal.Jc: Space characters in SimpleName ‘handles ConnectException’ are not allowed prior to DEX version 040
    This seems a bit awkward as Jvm Android modules can contain tests with backticks ( except instrumented tests ) Is there a solution/workaround? I could disable test
    androidTest
    if that would solve it ( how? ) as 99% of the code in the main source set
    j
    • 2
    • 3
  • q

    Qyhyzard

    12/17/2022, 4:59 AM
    Hello, every one! I am a new comer on KMM. I just followed the KMM getting started tutorial and chose Android Studio as my IDE. But as the picture shown, I faced a problem that i cannot jump to the swift UI definition in Android Studio and the code highlight and smart tip are not so good. In Xcode, the same code project behaves well. I learned from StackOverflow: Syntax highlighting not working for iosApp and they told me I should use XCode or AppCode. Is there any other way to code in the same IDE? Otherwise it may bring a bad developing experience. Anybody can share me some advices and offer some help? Thanks~
    j
    c
    • 3
    • 5
  • k

    Kshitij Patil

    12/17/2022, 1:13 PM
    I was thinking of way to share localised strings across platforms. On android, we use strings.xml which allows you to use them in both compose & xml layouts. Just curious what would happen if we replace them with kotlin objects instead. It’s a challenge for xml layouts, but for compose, you can totally use it. Moreover, we can build a shared library which will give you statically typed accessors for each key, across android, iOS and web. Has anyone tried something similar already?
    d
    h
    • 3
    • 2
  • r

    Russell Stewart

    12/17/2022, 9:30 PM
    What does this mean for the future of KMM? https://www.swift.org/blog/future-of-foundation/ As I understand it, K/N binds to Obj-C, not Swift, which allows it to access the iOS Foundation classes as Obj-C classes. If the Foundation is rewritten in Swift, that goes away, doesn't it? It seems to me that sooner or later, K/N will have to be bound directly to Swift for KMM to have a future, won't it? I haven't seen anything lately about Kotlin/Swift interop on the roadmap. Is JetBrains still working on that? I've really come to like KMM, and I'd hate to see Apple pull the rug out from under it.
    m
    b
    +3
    • 6
    • 8
  • w

    Waqas Tahir

    12/18/2022, 9:51 AM
    Today I tried kotlin react well kind of wanted to do something , with react and typescript and it didn't work Writing react ui in kotlin is very hard , I am very used to tsx and the interoperability between kotlin and typescript is pretty less , I mean expect it to work like java and kotlin Kotlin to Typescript Interoperability I would write code in typescript file or tsx for react components to be written inside typescript and then I would call the typescript react functions inside kotlin react , or be able to call kotlin functions inside typescript and kotlin compiler would handle the compilation of both to javascript , I don't know how this can be achieved but this would be ideal. Typescript can be like java just giving my opinion on what I expect would happen iin an ideal environment
  • m

    martmists

    12/18/2022, 1:39 PM
    Having some issues with my multiplatform project, trying to run the JVM main function in IntelliJ runs compileJava, but that seems to error, listing only the Android compileJava tasks:
    Cannot locate tasks that match ':ac-frontend:compileJava' as task 'compileJava' is ambiguous in project ':ac-frontend'. Candidates are: 'compileDebugAndroidTestJavaWithJavac', 'compileDebugJavaWithJavac', 'compileDebugUnitTestJavaWithJavac', 'compileReleaseJavaWithJavac', 'compileReleaseUnitTestJavaWithJavac'.
    If I add
    withJava
    to my
    kotlin { jvm { ... }}
    configuration, it complains it conflicts with the Android plugin. What do I do in this situation?
    v
    e
    • 3
    • 12
  • s

    spierce7

    12/18/2022, 6:31 PM
    In Gradle, if I wanted to iterate over all the dependencies in a multiplatform project for a specific platform, how would I do that?
    j
    c
    • 3
    • 14
  • d

    Daniel

    12/18/2022, 7:30 PM
    Suspension functions can be called only within coroutine body for the code doing a remove and after a logout:
    suspend fun doLogout(token: String) {
        val userId = appService.currentUser?.id
    
            realm.write {
    
                var user = query<UserInfo>("_id = $0", userId).first().find()
                if (user != null) {
                    val productIndex =
                        user.FCMToken.withIndex().findLast { it.value == token }!!.index
    
                    user = findLatest(user)!!.also {
                        it.FCMToken.removeAt(productIndex)
                    }
                    copyToRealm(user)
    
                    appService.currentUser?.logOut() // Suspension functions can be called only within coroutine body
    
                }
            }
    }
    Is there anyway to fix this without changing much code? I need to do first the db operation then logOut()
    c
    • 2
    • 3
  • k

    Ksenia Shneyveys

    12/19/2022, 10:44 AM
    🏆 The call for Kotlin Multiplatform contest applications is still open! Join #kotlin-multiplatform-contest to ask your questions.
  • h

    Hasan Nagizade

    12/19/2022, 5:02 PM
    What is the official recommended way to keep viewmodels? common code or platform specific(iosApp,androidApp) ?
    l
    c
    +2
    • 5
    • 10
Powered by Linen
Title
h

Hasan Nagizade

12/19/2022, 5:02 PM
What is the official recommended way to keep viewmodels? common code or platform specific(iosApp,androidApp) ?
l

Landry Norris

12/19/2022, 5:03 PM
There’s several ways to keep view models common. You can use moko-mvvm, stately, decompose, or others depending on what you need.
h

Hasan Nagizade

12/19/2022, 5:03 PM
@Landry Norris so there's no official guide about this?
c

Corey

12/19/2022, 5:24 PM
@Hasan Nagizade not really... KMM's pages likes to encourages shared business logic code and core. I have a personal preference that presentation logic must be in their own platform for now since I can use the full power of each without depending on "beta" stuff. Plus the communication between Swift <> Coroutines is way ugly and can pollute your codebase, so having your own iOS/Android VM will help in abstracting your shared code. The downside of having separate presentation logic is indeed the duplicated code.
I haven't tried it to have a shared VM but I have the feeling it can speed up the development, you can checkout the droidcon app for a pure shared VM code. I feel this one is a good source and I guess they don't use external libraries. 😄 Answering your question... yeah, no guidance at all.
h

Hasan Nagizade

12/19/2022, 5:30 PM
@Corey thank you very much for explanation.Right now my viewmodels are just kotlin classes used as KoinComponents in common code and initialised via Koin. I guess I will have to move them to androidApp and use Android's Viewmodel with it's pros and cons. I am still learning iOS so iOSApp part is empty for now
Thanks for the repository example too
c

Corey

12/19/2022, 5:33 PM
@Hasan Nagizade You can keep your VM in the common, if you want to use the Androidx ViewModel, then you can use
expect
and
actual
Since it is only Android for now, you can leave the iOS part empty. I'm doing the same, although I don't have a common VM, I've started with iOS only. Android is fully empty. 😄 😄
h

Hasan Nagizade

12/19/2022, 5:39 PM
@Corey what a nice coincidence. 😄 I hope you will like Jetpack Compose when you move to this side. 😁
s

Sam

12/19/2022, 8:40 PM
Common VMs work great assuming you're strict with your architecture, been using them with no issues
d

darkmoon_uk

12/20/2022, 12:49 AM
What is the official recommended way to keep viewmodels?
There's no official recommendation on this, and nor should there be: Your UI architecture is Application specific and this is out-of-scope of Kotlin Multiplatform. KMP is there to support code-sharing, whichever UI architecture you adopt. Generally though, if you're not attempting to share any of your presentation logic at all, then IMO you're missing out on the full benefit of Kotlin Multiplatform. Most of the time (KMM scenario) the View layer requirements are similar enough that it's straightforward to achieve a common (MVVM) ViewModel. Even where the UI differs greatly - for example, where in one of my projects I have a CLI client - you can still use KMP's 'hierarchical source-sets' to achieve e.g.
graphicalMain
that provides common VM sources for `ios`/`android` graphical targets, while the
cli
presentation layer can be separate and different.
View count: 32