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

    Trey

    09/13/2022, 3:39 PM
    I've got an existing KMM project that was created by the wizard. I'd like to add another target to create another app for Android that uses the shared module. Are there any instructions on all the edits I need to make to the project files to add another target to an existing workspace? I expect not, but I figured I would ask before I attempt it.
    m
    • 2
    • 3
  • a

    Andre

    09/14/2022, 1:17 PM
    Hello, I've got an almost working KMM project which I'm unable to build because of some import within an Objective C-Header file. The import itself is a due to a transitive dependency to OpenSSL_Universal (such as 'openssl/bn.h', for example). The gradle build fails with the following error: 'openssl/bn.h' file not found. This would also happen within iOS projects as long as OpenSSL_Universal is not declared as an explicit dependency. It is afaik not common for frameworks to ship transitive dependencies when it comes to the iOS Software Dev toolchain. So what I've done is to add OpenSSL_Universal to my set of Cocoapods dependencies within my build.gradle.kts - however, the build still fails. Is there a way to resolve the issue in a way similar to what you'd to when using XCode (e.g. declaring OpenSSL_Universal as an explicit dependency)?
  • m

    mattinger

    09/14/2022, 3:32 PM
    Has anyone had any luck getting cocoapods imported into a shared ios source source? Due to the way the presets work, there’s architecture specific versions (iosArm64 and iosX64). So i can create a source set for shared iOS code pretty easily. However, the problem is that I can’t manage to reference any cocoapods in it. Presumably because there’s additional work that has to go into configuring the preset which allows it to truly be an iOS specific module. I’d prefer to not have to repeat myself across the two ios architectures for all my code involving the pods i’m importing.
    j
    • 2
    • 19
  • s

    Sylvain Patenaude

    09/14/2022, 3:56 PM
    message has been deleted
  • j

    Jeff Lockhart

    09/14/2022, 5:54 PM
    Is there a way in gradle to remove a dependency from a parent source set, with the goal to replace with another variant of the same library?
    h
    • 2
    • 3
  • m

    MJegorovas

    09/15/2022, 7:42 AM
    Is it possible to export kotlin library as a cocoapods dependency or somehow generate obj-c bindings? I'm trying to create swift bindings for Flow like here, but in there XCFramework is used.
    v
    j
    • 3
    • 7
  • m

    mattinger

    09/15/2022, 1:18 PM
    Hi all. I think i’ve solved most of my source tree issues, and can now generate an XCFramework from the KMM project i’ve built. However, i’m getting the following error when I bring it into an xcode project:
    error build: Undefined symbol: _OBJC_CLASS_$_AnalyticsMultiplatformActionEventV5
    I’m kind of presuming that this is because the generated xcframework only contains ios-arm64 and ios-x86_44 versions (i’m on an m1). I tried to add the iosSimulatorArm64:
    iosSimulatorArm64 {
            binaries {
                framework {
                    baseName = "AnalyticsMultiplatform"
                    xcFramework.add(this)
                }
            }
        }
    
            val iosSimulatorArm64Main by getting {
                dependsOn(iosMain)
            }
    But assembling the framework always fails:
    the path does not point to a valid framework: .../analytics-multiplatform/build/analytics_multiplatformXCFrameworkTemp/fatframework/debug/iosSimulator/analytics_multiplatform.framework
    m
    • 2
    • 1
  • l

    Loboda Deni

    09/15/2022, 4:24 PM
    hi, i'm facing the problem:
    Module "dev.gitlive:firebase-auth" has a reference to symbol dev.gitlive.firebase.auth/FirebaseUser.displayName.<get-displayName>|-7122534302014937473[1]. Neither the module itself nor its dependencies contain such declaration.
    as far as I know there is some problem with the ir compiler, I updated the version of kotlin but the problem is still present. https://youtrack.jetbrains.com/issue/KT-48836 who faced this? Is there a solution to the problem without using custom library assemblies?
  • m

    mattinger

    09/15/2022, 5:47 PM
    Ok folks, XCFramework packaging question. I’m building an xcframework, which i brought into an iOS project (see above post). That XCFramework requires a pod, which i’ve put in my build.gradle.kts. I’ve managed to get things working, but i had to also import the pod i need directly into the actual iOS project. I tried setting up BITCODE inclusion in my framework:
    embedBitcode(org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode.BITCODE)
    but that always fails with
    DSJSONSchemaValidation/DSJSONSchemaValidation.framework/DSJSONSchemaValidation' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target.
    I suppose i can live with having to import both my framework and this pod into the project, since it’s only a single pod, but i think this would present a scaling problem if i had multiple pods, or multiple frameworks that have to do this. I’m wondering if this is just a function of the underlying DSJSONSchemaValidation pod and not incuding certain things.
  • l

    Loboda Deni

    09/15/2022, 6:23 PM
    after updating the version of kotlin to 1.7.10 I started getting the error "TypeError: undefined is not an object (evaluating 'tmp$ret$2.$metadata$')" and I can't figure out what is the reason. Has anyone encountered this? error happens in reflection.kt
    @JsName("getKClass1")
    internal fun <T : Any> getKClass1(jClass: JsClass<T>): KClass<T> {
        if (jClass === js("String")) return PrimitiveClasses.stringClass.unsafeCast<KClass<T>>()
    
        val metadata = jClass.asDynamic().`$metadata$` <--- error here
    • 1
    • 2
  • a

    adjpd

    09/15/2022, 8:03 PM
    Will JB ever put Swift syntax highlighting in IntelliJ? I often do small edits to the SwiftUI code from IntelliJ. Syntax highlighting would make it more pleasant.
    l
    b
    +2
    • 5
    • 13
  • a

    Ahmed Dridi

    09/16/2022, 12:29 PM
    Hey guys good morning. i am trying to publish a KMM library to maven central i hape followed this article https://dev.to/kotlin/how-to-build-and-publish-a-kotlin-multiplatform-library-going-public-4a8k but the publishment is always failing i am getting the error in the screenshot attached below.
    l
    m
    • 3
    • 4
  • g

    Guilherme Delgado

    09/16/2022, 11:57 PM
    Hi! Anyone trying to make a network call in jvm target (desktopApp) and getting:
    Exception in thread “main” java.lang.NoClassDefFoundError: java/net/http/HttpClient$Version
    It crashes when I try to provide
    ktor.HttpClient
    have no idea why 🤷‍♂️ (my DI setup is similar to other online samples, ex PeopleInSpace). I even tried something simpler like:
    actual fun platformModule() = module {
        single<HttpClient> { HttpClient(Java.create()) }
    }
    
    object HelperTest : KoinComponent {
        val httpClient = get<HttpClient>()
    }
    
    LaunchedEffect(Unit) {
        DependencyInjection.initKoin()
        println("${HelperTest.httpClient}") // BOOOM!
    }
    Thanks.
    • 1
    • 1
  • s

    Sergio C.

    09/17/2022, 3:07 PM
    Hello all! I'm thinking of converting some Android & iOS Apps to KMM Kotlin Multi platform Mobile. • What's your experiences when converting an existing mobile project to KMM? • What are the pain points and things you had to pay more attention to? • I use AndroidViewmodel in many ViewModels which depend on the Application Context, what is the best way to make this ViewModels non dependant on the Application Context?
    j
    a
    k
    • 4
    • 6
  • a

    Arjan van Wieringen

    09/18/2022, 11:51 AM
    Am I correct that when I create a multiplatform project with only a JVM target that the
    commonMain
    module is able to resolve
    java
    dependencies? That seems really weird to me.
    h
    p
    e
    • 4
    • 11
  • e

    Evan Foster

    09/18/2022, 4:41 PM
    I've been working to install KMM so I can work with it, and I've whittled down the errors that KDoctor throws to just one. That is a problem that the
    cocoapods-generate
    plugin is not found. I have installed it from Ruby, but it still shows this error. The docs say that if your Kotlin version is less that 1.7 you need to have
    cocoapods-generate
    , and I have Kotlin 1.7.10 installed, so am I safe to ignore this error? Or should I keep trying to install it, and if so, what am I doing wrong? Thanks!!
    k
    • 2
    • 1
  • s

    spierce7

    09/19/2022, 5:43 AM
    How are people doing multiplatform localization?
    a
    s
    +2
    • 5
    • 5
  • d

    david.bilik

    09/19/2022, 9:14 AM
    hey, I have this class
    sealed class State<out T> {
    
        object Loading : State<Nothing>()
        data class Error(val error: Throwable) : State<Nothing>()
        data class Loaded<out T>(val data: T) : State<T>()
    }
    in my shared kotlin code, then I have a viewmodel emitting these different states during async call. Now I want to check in my iOS swift code for a type of a State so I can either show loading/loaded/error views but I have a hard time figuring out how to do this type check. The only way where my type check succeeds is for the
    State.Loaded
    , but for Error or Loading it shows a warning
    Cast from 'State<Character>' to unrelated type 'StateLoading' always fails
    I suppose it’s because the Loading and Error does not have the type parameter, but how to do this properly?
    n
    o
    s
    • 4
    • 7
  • g

    Guilherme Delgado

    09/19/2022, 2:53 PM
    Hey!
    Task 😒hared:compileIosMainKotlinMetadata
    w: Could not find “io.ktor:ktor-utils-cinterop-threadUtils” in [/Users/user/MyApp, /Users/user/.konan/klib, /Users/user/.konan/kotlin-native-prebuilt-macos-aarch64-1.7.10/klib/common, /Users/user/.konan/kotlin-native-prebuilt-macos-aarch64-1.7.10/klib/platform/ios_arm64]
    w: Could not find “org.jetbrains.kotlin.native.platform.linux” in [/Users/user/MyApp, /Users/user/.konan/klib, /Users/user/.konan/kotlin-native-prebuilt-macos-aarch64-1.7.10/klib/common, /Users/user/.konan/kotlin-native-prebuilt-macos-aarch64-1.7.10/klib/platform/ios_arm64]
    I’m seeing this logs when building the project, it doesn’t fail, but what this concretely mean?
    t
    • 2
    • 2
  • n

    Nadeem Aslam

    09/20/2022, 5:53 AM
    Hey! I am trying to setup my system for KMM and i am facing an issue for hours.
    Cocoapods
    ruby (ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86_64-darwin21]) * System ruby is currently used Consider installing ruby 2.7 via Homebrew, rvm or other package manager in case of issues with CocoaPods installation ruby gems (3.0.3.1) cocoapods (1.11.3) * cocoapods-generate plugin not found Get cocoapods-generate from https://github.com/square/cocoapods-generate#installation Here is the stack overflow link for question. KMM KDoctor cocoapods error.
    k
    • 2
    • 6
  • a

    Ahmet Özcan

    09/20/2022, 3:36 PM
    Hi everyone, Do you know how can i add an aar file (3rd party dependency) to one of my multi platform module for android platform side i tried to create an empty folder with that build.gradle file and aar file
    configurations.maybeCreate("default")
    artifacts.add("default", file('3rd_party_sdk.aar'))
    then i add that as a dependency to my mainAndroid dependency and it worked but now there are bunch of errors when syncing gradle which also ends with success but i cant use any code complation etc.
    m
    • 2
    • 24
  • d

    diego-gomez-olvera

    09/20/2022, 3:47 PM
    hello everyone! I was wondering what would be the recommended way to make this code thread safe for multiplatform
    private var currentJob: Job? = null
    
    fun flushData() {
        if (currentJob?.isActive == true) return
        currentJob = scope.launch {
            // Flush data while there is data to flush
        }
    }
    The idea would be to avoid creating new unnecessary
    currentJob
    having
    flushData
    accessed potentially from any thread
    c
    • 2
    • 10
  • s

    Stylianos Gakis

    09/21/2022, 8:54 AM
    I was wondering, we are looking to move into using version catalogs for some KMP code. However we didn’t find a way to migrate dependencies that use
    npm
    like this one:
    implementation(npm("@emotion/styled", "x.x.x))
    . We can’t just define a dependency like
    emotion.styled = "@emotion/styled"
    since version catalogs is complaining. Is there any workaround we can do to get something like this working?
    e
    • 2
    • 2
  • t

    Trey

    09/21/2022, 6:14 PM
    Is there a class in Kotlin common that can be used like a WeakReference in Java? I see that there is a native version of this class. I'm confused why there isn't a common class that wraps the native implementations.
  • a

    Ahmet Özcan

    09/22/2022, 10:30 AM
    Hey again, Im having problem with cocoapods referenced from kmm module i added PubNub pod to one of my kmm modules but then i tried to build ios iget this error
    Undefined symbol: _OBJC_CLASS_$_PubNub
    Can you help me about that pls ty.
    k
    • 2
    • 11
  • j

    Javal

    09/22/2022, 12:40 PM
    Hello 👋 We have a kmm project and it was all good until we tried to run it on Xcode 14 😅 iOS is calling a shared api which is a suspend function. It was working fine till now but crashes in Xcode 14 with
    Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared
    Shared kotlin code:
    open val content: suspend () -> Content =
                { getContent() }
    getContent() calls other suspend function to retrieve data from local cache. iOS code:
    func getContent() async -> Content {
        await sharedGetApi.content.execute() //accessing shared `content` here.
    }
    
    
    extension KotlinSuspendFunction0 {
        func execute<T>() async -> T {
            do {
                let result: T? = try await self.invoke() as? T
                if let result = result {
                    return result
                } else {
                    fatalError("\(T.self) can not be nil")
                }
            } catch {
                fatalError(error.localizedDescription)
            }
    }
    library versions: coroutines = "1.6.3" kotlin = "1.6.10" Any help would be appreciated 🙏 TIA
    a
    • 2
    • 2
  • v

    Vojtěch Pešek

    09/22/2022, 12:58 PM
    TL;DR: Is it possible to disable the generation of
    componentX()
    methods on
    data class
    ? Hi, we have a kmm project for android and iOS targets. Currently, i’ve been working on reducing the library size and especially the library objc header for iOS. I noticed that `data class`es generate component methods for each value in the constructor. This is what I would expect. Those
    componentX()
    methods also appear in the header, but usually there is no need for the iOS developers to call the method. This is because they can call the parameter by name, which is far more descriptive.
    j
    s
    +2
    • 5
    • 10
  • a

    Arun Joseph

    09/22/2022, 4:05 PM
    Hi All, Looking for an information for new project. - what is the percent of KMM code can we share in a iOS/Android project with clean architecture. Is anyone willing to share in their experience how much percent reuse you achieved?
    t
    m
    s
    • 4
    • 6
  • j

    Jared Vu

    09/22/2022, 4:51 PM
    Hi 👋 my team has been writing shared business logic in KMM for our native apps and web apps. When our kotlin data classes is exported to JS the
    val
    names are replaced. For the given class,
    @JsExport
    data class Foo (
      val configs: Configs?,
    )
    I would expect the exported JS to have a key
    configs
    but instead it is replaced with
    this.b1q_1 = configs;
    Is there any way to preserve the human readable val names within our exported class?
    e
    b
    +3
    • 6
    • 67
  • p

    Phạm Nhật

    09/23/2022, 6:56 AM
    Hi everyone. My team is planning for building multi-pods in multi-module projects world, is this limitation currently resolved or any workarounds available? https://kotlinlang.slack.com/archives/C3PQML5NU/p1631615128335100
    m
    • 2
    • 2
Powered by Linen
Title
p

Phạm Nhật

09/23/2022, 6:56 AM
Hi everyone. My team is planning for building multi-pods in multi-module projects world, is this limitation currently resolved or any workarounds available? https://kotlinlang.slack.com/archives/C3PQML5NU/p1631615128335100
m

Matthias Geisler

09/23/2022, 7:51 AM
https://youtrack.jetbrains.com/issue/KT-42250/Support-compiling-Kotlin-module-to-SwiftObj-C-module-that-doesnt-contain-all-dependencies
p

Phạm Nhật

09/23/2022, 11:06 AM
Thanks @Matthias Geisler 👍. Looks like the support is not yet available.
View count: 33