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

    Sourabh Rawat

    10/22/2020, 8:44 AM
    How to run a full stack web app in continuous mode ?
    b
    53 replies · 2 participants
  • n

    ntherning

    10/22/2020, 11:42 AM
    Hi folks! I want to share how we are invoking Gradle from our Xcode project when building our iOS app. We only build the configuration (Release/Debug/simulator/device) actually requested by Xcode. We also generate a dependencies file (Makefile style
    .d
    -file) which Xcode uses to determine whether Gradle needs to be run at all. Xcode will discover changes to
    .kt
    files (which we edit in Android Studio, they aren't part of the Xcode project), changes to the Gradle files, etc and only then rebuild the framework. It works nicely so far. Would be great to get some feedback on the approach. https://gist.github.com/ntherning/dafd5979bdfb660bbf516066ca056931
    ❤️ 2
    e
    3 replies · 2 participants
  • l

    leandro

    10/22/2020, 1:04 PM
    Anyone having issues declaring
    coreLibraryDesugaring
    inside
    androidMain
    dependencies? It seems that this function does not exist for the
    multiplatform
    plugin
    j
    p
    11 replies · 3 participants
  • e

    Elka

    10/22/2020, 2:05 PM
    Does anyone have any idea if Kotlin will ever support having these kind of dependencies? With the current Kotlin version, we end up with redundant classes because module are being built separately.
    ☝️ 2
    k
    2 replies · 2 participants
  • r

    rocketraman

    10/22/2020, 8:32 PM
    What's the best IDE to use on a Mac to be able to open a KMM project and edit both Swift code and Kotlin/Native? I've tried using Appcode with the K/N plugin but it dosen't really seem to understand my project. It ignores the top-level gradle file. If I use the Xcode workspace to open the project, and I can't seem to import my existing shared library code.
    b
    h
    13 replies · 3 participants
  • s

    Sebastien Leclerc Lavallee

    10/23/2020, 3:52 AM
    I’m trying to make the Cocoapods plugin working with iOS app (Tried official and Touchlab fork). I’ve enabled the plugin and generated my podspec file (also fix the path of the script because my setup is a bit different). It does create the “dummy” framework in
    shared/build/cocoapods/framework/shared.framework
    Back to the ios folder, I’m doing
    pod install
    and it does install everything. When I hit build, it fails with error like
    could not build module shared
    . When inspecting the imported shared.framwork, I see it’s still have the
    dummy.h
    so makes me think the sync didn’t worked. Where can I get more info about that
    before_compile
    script which calls task
    gradlew shared:syncFramework
    ? Also, I did try to manually call the
    ./gradle shared:syncFramework
    task but it fails with
    Task syncFramework not found in project shared
    . Why? Did checkout Touchlab’s KampKit and can compile without any issue… when comparing what they did, it’s pretty much the same. I’m clearly missing something but can’t point exactly what… Anyone with some hint? Thanks!
    j
    r
    +1
    5 replies · 4 participants
  • v

    Vinod Rai

    10/23/2020, 6:13 AM
    trying to generate .js file so it can be used like other .js files in HTML but getting this error.
    Could not create an instance of type org.jetbrains.kotlin.gradle.targets.js.subtargets.KotlinBrowserJs.
    > Failed to apply plugin [class 'org.gradle.language.base.plugins.LifecycleBasePlugin']
       > Cannot add task 'clean' as a task with that name already exists.
    Here is the common code Gradle for js source.
    js {
            moduleName = "EmtCore"
            binaries.executable()
            browser {
                webpackTask {
                    outputFileName = "$moduleName.js"
                }
                runTask {
                    outputFileName = "$moduleName.js"
                }
            }
        }
    can anyone guide how to generate .js file
    x
    1 reply · 2 participants
  • s

    Sebouh Aguehian

    10/23/2020, 10:51 AM
    I’m testing Android Studio KMM plugin (0.1.3-release-54-Studio4.1). When I add a cinterop dependency to the iOS shared code, debugging a unit test no longer works. It seems gradle waits on
    :shared:iosTest
    forever. Has anyone experience this before?
    a
    8 replies · 2 participants
  • j

    joney

    10/24/2020, 10:20 PM
    Is t here a way to use
    runBlockingTest
    of [TestCoroutineScope](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-test/kotlinx.coroutines.test/-test-coroutine-scope/) for native tests?
    🇳🇴 1
    t
    2 replies · 2 participants
  • h

    Hyun

    10/25/2020, 4:13 PM
    Hi, everyone. I need some advice for this architecture sample I shared the sample previously. but I added some improvement. Sample supports • To share VIewModel Android, Ios both • To share Navigation stack by Android, Ios both • To use ‘function’ way to draw on Compose, SwiftUi both as able to share Navigation. View side code got simpler just drawing UI and deliver user action to viewModel. dependency between each Screen is removed. just ViewModel interact between viewModels. I’m wondering if this is fine approach. Android
    fun SampleScreen(val model: SampleViewModel) {
        Screen(model) {
            Column {
                Text("greeting : ${+model.greeting}")
                Text("reply result : ${+model.replyResult}")
                Button("Reply") { model.onClick() }
            }
        }
    }
    Ios • code looks similar though if ui is complicated, code also not be similar.
    func SampleScreen(_ model: ApiSingleViewModel) -> some View {
        Screen(model) {
            Column {
                Text("current value : \(+model.greeting ?? "")")
                Text("reply result : \(+model.replyResult ?? "")")
                Button("Reply") { model.onClick() }
            }
        }
    }
    Common
    class SampleViewModel(val api: SampleApi = serviceLocator.sampleApi) : BaseViewModel() {
    
        //[add] is for ios to watch each Flow, DataFlow will be migrated to SharedFlow
        val greeting by add { DataFlow<String>() }
        val replyResult by add { DataFlow<String>() }
    
        override fun onInitialized() {
            //initStatus handle error and loading ui, also retry on error
            greeting.load(initStatus) {
                api.getGreeting("Hyun", "Programmer")
            }
        }
    
        fun onClick() {
            //initStatus hide ui on loading, error.
            //status doesn't hide ui but show loading, error ui
            replyResult.load(status) {
                api.reply("Thanks")
                navigate(SomeOtherViewModel()) // you can navigate this way.
            }
        }
    }
    a
    3 replies · 2 participants
  • m

    Matthew Rees

    10/26/2020, 8:39 AM
    Hi all, using the Android Studio MMP template in Android Studio the with the new iOS architecture with Kotlin 1.4 it produces a module with supported platforms -
    Selected Target platforms: Native (ios_arm64), Native (ios_x64)
    but when manually creating a module in IntelliJ there is no way to create a module with multiple targets? There’s a
    Target Platform: Multiplatform
    but this does not allow the use of the iOS platform libraries. Should I just scrap my existing project and use the new Template, or is there something I’m missing?
    w
    1 reply · 2 participants
  • w

    william

    10/26/2020, 12:40 PM
    does anyone have suggestions for learning more about the native ios memory model and object subgraph freezing? I have read through the kotlin docs on it but still feel a bit confused
    a
    f
    3 replies · 3 participants
  • s

    saket

    10/27/2020, 2:21 AM
    I’m unable to add a
    common
    dependency to my project because gradle is trying to find an artifact named
    file-macosx64
    whereas the actual name is
    file-macosX64
    (lowercase vs uppercase
    X
    ) This is probably a general gradle question, but is there a way to help gradle find the correct artifact?
    1 reply · 1 participant
  • u

    Umar Ata

    10/27/2020, 10:21 AM
    Please let me know the minimum iOS os version that support kotlin multiplatform
    w
    r
    +2
    7 replies · 5 participants
  • m

    Maurice Wingbermuhle

    10/27/2020, 1:23 PM
    Hi All, Since Kotlin 1.4, the automatic translation of suspend methods is making our iOS API fail with ambiguous methods. That is because we've defined an interface with a suspend method, for use in Kotlin, and 2 special overloads with callback/completions for Jvm(Android) and iOS. The suspend method and iOS specific method are marked with
    @JvmSynthetic
    to hide them from the JVM API. I am now wondering if there is similar annotation to make methods hidden from the iOS (Objective-C) API, so I can hide the suspend method, effectively disabling the automatic conversion.
    s
    2 replies · 2 participants
  • d

    dazza5000

    10/27/2020, 8:41 PM
    is there a multiplatform package format that can be used as a dependency in other multiplatform projects?
    k
    b
    14 replies · 3 participants
  • d

    Daniele B

    10/28/2020, 5:05 PM
    given a Kotlin enum
    MyEnum
    , on Kotlin, it is possible to retrieve the list of all enum values with
    MyEnum.values()
    what about in Swift?
    .values()
    doesn’t seem defined in the
    MyEnum
    object in Swift
    a
    4 replies · 2 participants
  • d

    Daniele B

    10/28/2020, 5:55 PM
    what about package variables? is it possible to retrieve them from Swift? for example, this is declared inside a file in commonMain:
    package com.project.shared.valuedefs
    
    val myList = listOf("A","B","C")
    can I access it from Swift and how?
    k
    3 replies · 2 participants
  • s

    Samuel Michael

    10/28/2020, 6:56 PM
    Anyone have a github repo for a kmm plugin project with additional javascript target? Keep breaking my library when I try to add the js target, just a simple example if it is possible would be much appreciated
    f
    t
    5 replies · 3 participants
  • w

    william

    10/28/2020, 8:05 PM
    anyone know of repos to look at using multithreading coroutines with multiplatform?
    b
    m
    9 replies · 3 participants
  • t

    Tristan Hamilton

    10/29/2020, 4:49 PM
    hey! looks like last mention of default implementations for expect declarations was over a year ago in this channel. Anyone here know of updates regarding it? https://youtrack.jetbrains.com/issue/KT-20427
    ➕ 2
    k
    z
    +1
    5 replies · 4 participants
  • d

    dazza5000

    10/29/2020, 6:21 PM
    is there a way to quiet the compiler if you are creating multiplatform classes, but dont want to implement it on one platform (for instance you want android/ios, but not a js implentation)
    c
    5 replies · 2 participants
  • d

    drofwarcs

    10/30/2020, 1:36 AM
    When enabling HMPP and using the
    ios()
    shortcut, I'm noticing that commonizer does not add the optional methods on protocols. For example UITableviewDataSource has 11 methods, but the commonizer is only creating variants that only have the 2 required methods of that protocol. These 11 methods exist on both iosX64 and iosArm64, so figured the commonized versions should also have all the methods. Is this by design or is this a bug?
    b
    3 replies · 2 participants
  • n

    nrobi

    10/30/2020, 11:53 AM
    🎊 https://blog.jetbrains.com/kotlin/2020/10/kotlinx-coroutines-1-4-0-introducing-stateflow-and-sharedflow/
    🎉 8
    t
    1 reply · 2 participants
  • d

    dazza5000

    10/30/2020, 5:35 PM
    is there a plan to support android + jvm targets at the same time - noticed this in the kotlin mp docs
    We don't currently support sharing a source set for these combinations:
    
        Several JVM targets
        JVM + Android targets
        Several JS targets
    b
    k
    +2
    17 replies · 5 participants
  • n

    Nikita Khlebushkin

    10/30/2020, 8:12 PM
    Hello! I’m writing a library for KMM, and I would need to have: commonMain/…/RxUtils.kt:
    expect class Observable<T>
    androidMain/…/RxUtils.kt:
    actual typealias Observable<T> = io.reactivex.rxjava3.core.Observable<T>
    …but:
    s
    11 replies · 2 participants
  • r

    rsetkus

    10/30/2020, 9:16 PM
    Hi. Not sure if multiplatform channel is the right place and even not sure if that is possible. So, I am generating Kotlin response/request data classes used by Ktor. I'd like to keep them separate from common module. Created another module and included
    api(project(":generatedapi"))
    it as a dependency to common module. It compiles and builds successfully but when I publish the project as a library, those generated classes are not included so clients which are using multiplatform library cannot access them. Does anybody tried to achive something similar like this or maybe know a way how to expose dependency classes to clients? Thanks.
    b
    32 replies · 2 participants
  • s

    saket

    10/30/2020, 10:59 PM
    Kotlin/native is unable to find a carthage framework linked through cinterop when running tests. I’m able to use them fine from kotlin/native. Can someone please check? I’ve been banging my head for a while.
    e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
    
    The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
    output:
    ld: framework not found ObjectiveGit
    
    > Task :shared:linkDebugTestMacos FAILED
    build.gradle
    fromPreset(presets.macosX64, "macos") {
      compilations.main {
        cinterops {
          objectivegit {
            defFile "src/nativeInterop/cinterop/objectivegit.def"
            compilerOpts "-F$projectDir/Carthage/Build/Mac/"
          }
        }
      }
    }
    objectivegit.def
    depends = Foundation
    package = libgit2.ObjectiveGit
    language = Objective-C
    modules = ObjectiveGit
    
    compilerOpts = -framework ObjectiveGit
    linkerOpts = -framework ObjectiveGit
    t
    2 replies · 2 participants
  • w

    william

    10/31/2020, 2:53 PM
    i have a
    suspend fun
    in my kotlin shared code but I have been unable to see it in swift. It shows up in the objective-c framework but for whatever reason Xcode doesn't see it when i am writing swift. any ideas? I am using kotlin 1.4.10
    c
    1 reply · 2 participants
  • m

    Mustafa Ozhan

    11/01/2020, 12:38 PM
    Is there any way to extend a kotlin class in common from
    Combine > ObservedObject
    so that we can use as
    @ObservedObject
    in SwiftUI views ? Or do we have to create a wrapper for each viewModel ?
    j
    s
    5 replies · 3 participants
Powered by Linen
Title
m

Mustafa Ozhan

11/01/2020, 12:38 PM
Is there any way to extend a kotlin class in common from
Combine > ObservedObject
so that we can use as
@ObservedObject
in SwiftUI views ? Or do we have to create a wrapper for each viewModel ?
j

John O'Reilly

11/01/2020, 1:03 PM
Just my 2c but I think in that case there's isn't a lot of value in having view models in shared code....what you might have though are what I think of as "view model helper" classes that are then used by "native" view model (based on ObservableObject on iOS and AAC ViewModel on Android)
☝️ 1
or perhaps something like that described in https://www.marcogomiero.com/posts/2020/kmm-shared-app-architecture/
m

Mustafa Ozhan

11/01/2020, 1:31 PM
Thank you for you reply, yes i read this one, it is really interesting one and has many benefits, but I do not like the idea of creating view model in each platform for each screen. Because we can achieve viewModel for Android and JS in common probably it will be better to duplicate only on IOS side. On the other hand I am really wondering if I really need to use
Combine, ObservedObject
with
@ObservedObject
and
@Published
vars on IOS side or better to use straightforward approach like here: https://github.com/kuuuurt/jokes-app-multiplatform/blob/master/ios/JokesApp/ViewController.swift
👍🏻 1
s

saket

11/01/2020, 5:17 PM
I'm using a container view to subscribe to presenter models: https://github.com/saket/press/blob/27526c7b6ce0073cfbdfc66f1e530bc96193992b/native/mac/mac/Home/HomeView.swift#L28
m

Mustafa Ozhan

11/01/2020, 10:08 PM
this one was interesting too will try this also thanks a lot!
View count: 6