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

    Sean

    12/10/2020, 3:08 AM
    Heya, Any advice for a rookie on figuring out how to get started with multiplatform for android + web (planning on firebase handling the backend)? I can use the new project template from the android studio plugin, and I found the KaMPKit and MOKO templates, but those are all for android/iOS. Which causes two problems, one is I don't have a mac so the iOS side is busted, and two the whole reason I want a template is because I'm in over my head tinkering with a dev environment (Gradle especially) so the webapp not being there at all is not great. Maybe I'm expecting too much for something so new though, I can always just work on a native kotlin/android app and worry about the web side later. Thanks!
    r
    • 2
    • 2
  • p

    Paul Woitaschek

    12/10/2020, 8:03 AM
    I want to encode the version of my library in the framework. Currently in the plist, the
    CFBundleVersion
    is always
    1
    . How can I set this value?
    l
    • 2
    • 4
  • a

    Alfred Lopez

    12/10/2020, 1:08 PM
    I’ve searched this channel for answer to this, and found nothing (perhaps I’m doing it wrong :-) ), but is there a way to do the following using KClass... Class.forName(...).newInstance()
    s
    • 2
    • 4
  • h

    Halil Ozercan

    12/10/2020, 1:18 PM
    Is there anyone who is experiencing a similar issue to this one https://youtrack.jetbrains.com/issue/KTOR-1071 ? I'm trying to make a request to an
    https
    endpoint and it fails on MacOS app with
    kotlin.IllegalStateException: TLS sessions are not supported on Native platform
    l
    • 2
    • 1
  • a

    Animesh Sahu

    12/10/2020, 2:01 PM
    I don't see SimplePlatform class described in the video

    Diving into Kotlin Multiplatform▾

    at timestamp 27m 34s. Anybody tried using it, to define targets like allExceptJs or something?
    r
    s
    • 3
    • 4
  • d

    Daniele B

    12/10/2020, 2:42 PM
    About MVI and Multiplatform: All articles talking about MVI with Kotlin I have been reading just deal with Kotlin/Android and not with Kotlin/MultiPlatform. They all seem to use SealedClasses for defining the Intents. For any event, the Android UI layer references a Sealed Class Intent. However in a multiplatform context, on iOS is not really possible to reference a SealedClass Intent, AFAIK. For this reason, my MVI/KMP implementation doesn’t use Sealed Classes for Intents, but just standard functions defined on the shared ViewModel. I wonder if anyone has some different suggestions.
    a
    j
    +2
    • 5
    • 12
  • j

    jean

    12/10/2020, 3:05 PM
    I’m trying to integrate mixpanel to a js target but I’m not sure how to do it. That’s what I have for ios :
    import cocoapods.Mixpanel.Mixpanel
    
    actual class MixpanelFactory {
        actual fun createTracker(): Tracker {
            val actualMixpanel = Mixpanel("", mapOf<Any?, Any>(), 0)
            return object : Tracker {
                override fun sendEvent(event: Event) {
                    actualMixpanel.track(event.name, event.asMap() as Map<Any?, Any>)
                }
            }
        }
    }
    I did add the npm dependency for the js target and tried something like this, to not avail :
    @JsModule("mixpanel-browser")
    external val mixpanel: Mixpanel
    
    actual class MixpanelFactory {
        actual fun createTracker(): Tracker {
            val actualMixpanel = Mixpanel("")
            return object : Tracker {
                override fun sendEvent(event: Event) {
                    actualMixpanel.track(event.name, event.asMap())
                }
            }
        }
    }
    
    // js code to use
    var mixpanel = require('mixpanel-browser');
    mixpanel.init("YOUR_TOKEN");
    mixpanel.track("Sign up");
    • 1
    • 1
  • a

    Alfred Lopez

    12/10/2020, 3:26 PM
    @Vsevolod Ganin It happens to me too, but I"ve noticed that IntelliJ does know what you're coding based on the module and it will "code complete" appropriately. For example, if I'm editing a Kotlin file in commonMain and I have java.util.*, IntelliJ tells me it cannot find it, but if I'm editing a Kotlin file in jvmMain that has the same line, then it "finds it". It could be a real feature, a fluke, or I'm imagining it all. 🙂
    v
    • 2
    • 4
  • j

    James Sherlock

    12/10/2020, 3:31 PM
    Bit of a bizarre one but has anyone had any success with an iOS app using purely Swift Package Manager? We've got a branch working using the CocoaPods plugin in conjunction with https://github.com/ge-org/multiplatform-swiftpackage - the iOS app itself completely ignores the pods and only brings in things via SPM but we have a dependency on Firebase which is now freaking out with the SPM plugin when we remove CocoaPods from the Kotlin side of things.
    ld: framework not found FirebaseFirestore
    (as part of the linkReleaseFrameworkIosArm64 step) We're hoping to try and completely remove Pods but it looks like the KMM project can't build without it? Any guidance appreciated 🙏 Thank you
    • 1
    • 1
  • e

    Elyes Ben Salah

    12/10/2020, 4:19 PM
    Hi guys , I would like to know how to import and use a KLib
    k
    • 2
    • 8
  • d

    Daniele B

    12/10/2020, 4:59 PM
    Trying to describe in the simplest way the difference between KMP, Flutter and ReactNative
    j
    j
    +4
    • 7
    • 53
  • s

    SrSouza

    12/10/2020, 7:39 PM
    Hi folks, anyone has an example of using StateFlow in SwiftUI?
    d
    r
    • 3
    • 2
  • e

    Eduard Mayer

    12/11/2020, 2:41 PM
    Hey there, i got a problem when embedding bitcode to our kotlin mpp library. As soon as i add
    ios {
      binaries {
        framework {
          embedBitcode("bitcode")
        }
      }
    }
    to my build.gradle.kts, i get the following error:
    * Where:
    Build file '/Users/me/projects/shared-sdk/build.gradle.kts' line: 73
    
    * What went wrong:
    Cannot create binary debugFramework: binary with such a name already exists
    which points exactly to the above snippet. Did anybody encounter the same? As soon as i remove it, it works, but i can't archive the ios app to throw it at AppStore Connect, because the bitcode is missing. The full
    build.gradle.kts
    and error log is attached here at this gist: https://gist.github.com/vsxed/3987c535cf98160a7a48b852fb9e4c64
    a
    • 2
    • 2
  • j

    jean

    12/11/2020, 4:53 PM
    Is there a way to specify a pod dependency fo a specific target? I have this now
    cocoapods {
        ...
        // only for ios target
        pod("Mixpanel")
    
        // only for tvos
        pod("Mixpanel/tvOS")
    }
    I saw it’s possible to add a cocoapods in each target block, but that means a lot of redundant code
    y
    • 2
    • 7
  • j

    Javier

    12/11/2020, 7:09 PM
    Is it possible to avoid common tests running on a specific platform?
    r
    • 2
    • 5
  • a

    Amritansh

    12/11/2020, 8:35 PM
    Hi, I am trying to integrate a KMM library into my existing android project but I am getting this error when I try to run the app
    Duplicate class kotlinx.coroutines.AbstractCoroutine found in modules jetified-kotlinx-coroutines-core-1.3.5.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5) and jetified-kotlinx-coroutines-core-jvm-1.3.9-native-mt-2.jar (org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.3.9-native-mt-2
    My android app uses following versions
    const val coroutines_core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5"
        const val coroutines_android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5"
        const val coroutines_test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.5"
    But my KMM library uses
    1.3.9-native-mt-2
    Any idea how can I resolve this?
    • 1
    • 1
  • b

    bod

    12/12/2020, 4:23 PM
    Hello, World! In gradle kts file, isn't there a syntax to be able to declare a dependency like this
    implementation("group", "artifact", version)
    instead of
    implementation("group:artifact:$version")
    ? I could write a small fun for this of course but first checking if I'm not missing something that already exist?
    m
    l
    • 3
    • 6
  • b

    bod

    12/12/2020, 6:15 PM
    Unrelated: I cannot seem to manage to use
    android { kotlinOptions {
    in kts (it works in regular gradle). And I need this to set
    jvmTarget
    to 1.8. It says
    Unresolved reference kotlinOptions
    . I verified that this syntax does work on non multiplatform android build files, with kts.
    a
    t
    k
    • 4
    • 4
  • a

    Arkangel

    12/12/2020, 9:21 PM
    but intellij isn’t recognizing Json.stringify or Json.encode
    t
    • 2
    • 1
  • a

    andylamax

    12/14/2020, 9:09 AM
    Since kotlin 1.4, setting up gradle for multiplatform project has surely been super easy. Kudos to the whole team behind that amazing api
    :true-story: 6
    💯 9
    a
    i
    • 3
    • 3
  • m

    Mikołaj Kąkol

    12/14/2020, 9:42 AM
    Hello, I have project with multiple modules, among them there is
    shared
    module that depend on (almost) all other modules. When building
    UniversalFramework
    it's headers doesn't contain classes from submodules unless exposed in shared API. Any idea how to make all classes visible to iOS?
    ✅ 1
    • 1
    • 1
  • a

    Azur Haljeta

    12/14/2020, 9:45 AM
    Is it true that only pure Objective-C cocoapods can be included in a KMM project? I found this Starscream library for WebSockets, it seems very popular among iOS developers but it's written in Swift.
    :nope: 1
    m
    s
    +4
    • 7
    • 16
  • a

    Alfred Lopez

    12/14/2020, 3:35 PM
    Is there a kotlin equivalent to java.security.*?
    j
    • 2
    • 4
  • a

    arnis71

    12/14/2020, 6:31 PM
    Hello, has anyone tried to add cocoapods integration for
    ios()
    target? I’ve found that imports for cocoapods dependencies in
    iosMain
    do not work. Only if i specify
    iosArm64()
    or
    iosX64()
    target it starts working. Is it supposed to be like this? If so how can I use cocoapods dependencies for all ios targets at once?
    a
    m
    a
    • 4
    • 5
  • a

    Amritansh

    12/14/2020, 9:52 PM
    Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug'
    I am getting No matching variant when I try to add my KMM library to my android app via maven local repository. I have added
    id("com.android.library")
    at the top of plugin list and also added
    kotlin {
        android {
            publishLibraryVariants("release", "debug")
        }
    }
    I have also specified matching fall back for debug in my library's build.gradle
    buildTypes {
        getByName("release") {
            isMinifyEnabled = false
        }
        getByName("debug"){
            matchingFallbacks.add("release")
        }
    }
    Any help will be appreciated
    r
    • 2
    • 3
  • j

    Jeff Tycz

    12/15/2020, 2:30 AM
    Hopefully this isn't a silly question but is it possible to for a non-multiplatform Android app to use a multiplatform library? My intention is to have a library that can be used for both non-multiplatform projects and multiplatform projects. Is this even possible?
    a
    k
    m
    • 4
    • 8
  • t

    travis

    12/15/2020, 9:16 AM
    🎉 Excited to share with the community a Bluetooth Low Energy library we've been working on called Kable. Version:
    0.1.0
    Features: • :kotlin: multiplatform, currently supports :android: , :javascript: and macOS targets, with additional targets planned in the future • Simple/unified :coroutine: Coroutines-powered API • Persistent characteristic observations (
    Flow
    remains active across reconnects) • Demo/sample app Feedback and 🐛 bug reports are appreciated/welcome.
    👍 24
    😮 9
    :kotlin-intensifies: 19
    b
    z
    • 3
    • 3
  • a

    Alfred Lopez

    12/15/2020, 12:40 PM
    Can java.io be used in multiplatform or is there an equivalent kotlin package that I need to use? Or is there a "multiplatform" properties file loader that anybody knows about? Thanks!
    a
    m
    +3
    • 6
    • 26
  • s

    Shan

    12/16/2020, 4:24 AM
    Looks like in Kotlin 1.4.21 the
    sources.jar
    is not being generated for the
    kotlinMultiplatform
    publishing target; was this change intentional does anyone know? I can still acquire a source jar with the
    metadataSourcesJar
    and append it to my common publishing task, but not sure if this is a bug or intended.
    t
    c
    • 3
    • 3
  • e

    Eirik Vale Aase

    12/16/2020, 12:25 PM
    Hi all 🙂 When it comes to supporting OAuth2 login flows in a KMM app (iOS, Android), what is the preferred solution? It’s not clear to me that ktor supports it (haven’t found any guides). I guess doing it natively on each platform is the way forward? I’ve been searching in this Slack, and found some relevant things. • kotlinlang#ktor
    m
    b
    • 3
    • 6
Powered by Linen
Title
e

Eirik Vale Aase

12/16/2020, 12:25 PM
Hi all 🙂 When it comes to supporting OAuth2 login flows in a KMM app (iOS, Android), what is the preferred solution? It’s not clear to me that ktor supports it (haven’t found any guides). I guess doing it natively on each platform is the way forward? I’ve been searching in this Slack, and found some relevant things. • kotlinlang#ktor
m

mbonnin

12/16/2020, 12:35 PM
I wrote this Feature some time ago: https://github.com/HearthSim/Arcane-Tracker/blob/5ea32b40806fb748d0758b8e1488ae030[…]pi/src/commonMain/kotlin/net/hearthsim/hsreplay/OauthFeature.kt
It's mostly obsolete now but can be used as a starting point for another implementation
e

Eirik Vale Aase

12/16/2020, 12:54 PM
Thanks so much for your response, I will look into it 🙂 In what way is it obsolete? I’m fairly new to Kotlin and KMM.
m

mbonnin

12/16/2020, 12:56 PM
Not sure, it might still work but it was written something like 9 months ago which is ages in the MPP world
e

Eirik Vale Aase

12/16/2020, 12:57 PM
True, thanks 👍
b

Benjamin Charais

12/16/2020, 7:27 PM
My team has recently implemented OAuth utilizing Ktor on a multiplatform project, we did have to write almost the entire exchange manually, but ktor does work reasonably well.
View count: 5