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

    Fanis Paschos

    02/11/2021, 2:19 PM
    Hello everyone, I have an issue when building my KMM Project w/ AppCenter. To begin with, I have a sample Android & iOS application. I have integrated KMM into my Android sample project and manually configured the Multiplatform project to create an iOS framework, so as my iOS project to use it. Furthermore, I have my Android and iOS in different repos and I have created a submodule into the Android repository in order to bring the iOS application inside the ΚΜΜ project folder. The issue occurs, when I am trying to build my iOS Application in AppCenter (the automation platform I am using to build my projects), due to the fact that Android & iOS are in different GitHub repositories. A small but unfortunately not very productive workaround, might be to manually create my iOS Framework and input it every single time in iOS, which is of course makes all the CI/CD process counterproductive. Is there a way to have separate and synchronised repositories for Android & iOS for my ΚΜΜ project? Thank you all!!
    b
    p
    • 3
    • 4
  • j

    Jack Darlington

    02/11/2021, 3:01 PM
    Hi, I get a compiler error for compileKotlinIosX64:
    e: Compilation failed: An operation is not implemented: Not yet implemented
    
     * Source files: MutableStateFlow.kt, FormattedStringFactory.kt, VideoUtils.kt, RevolutionData.kt, RoutineViewModelDto.kt, ExerciseState.kt, RevolutionData.kt, Routine.kt, AndroidSerialization.kt, SerializationExtension.kt, Image.kt, SocketEvents.kt, FormattedStringFactory.kt, Parcelable.kt, Image.kt, MutableStateFlow.kt
     * Compiler version info: Konan: 1.4.21 / Kotlin: 1.4.21
     * Output kind: LIBRARY
    
    e: kotlin.NotImplementedError: An operation is not implemented: Not yet implemented
    	at org.jetbrains.kotlin.backend.konan.serialization.KonanIrLinker.getTranslationPluginContext(KonanIrlinker.kt:94)
    	at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.tryResolveCustomDeclaration(KotlinIrLinker.kt:546)
    	at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.getDeclaration(KotlinIrLinker.kt:566)
    	at org.jetbrains.kotlin.ir.util.ExternalDependenciesGeneratorKt.getDeclaration(ExternalDependenciesGenerator.kt:60)
    	at org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator.generateUnboundSymbolsAsDependencies(ExternalDependenciesGenerator.kt:50)
    	at org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator.generateUnboundSymbolsAsDependencies(ModuleGenerator.kt:62)
    	at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:89)
    	at org.jetbrains.kotlin.backend.konan.PsiToIrKt.psiToIr(PsiToIr.kt:126)
    	at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$psiToIrPhase$1.invoke(ToplevelPhases.kt:134)
    	at org.jetbrains.kotlin.backend.konan.ToplevelPhasesKt$psiToIrPhase$1.invoke(ToplevelPhases.kt)
    	at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$namedOpUnitPhase$1.invoke(PhaseBuilders.kt:97)
    	at org.jetbrains.kotlin.backend.common.phaser.PhaseBuildersKt$namedOpUnitPhase$1.invoke(PhaseBuilders.kt:95)
    	at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:94)
    	at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:30)
    	at org.jetbrains.kotlin.backend.common.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:94)
    	at org.jetbrains.kotlin.backend.common.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:41)
    	at org.jetbrains.kotlin.backend.konan.KonanDriverKt.runTopLevelPhases(KonanDriver.kt:29)
    	at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:78)
    ....
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':base:compileKotlinIosX64'.
    > Compilation finished with errors
    I looked online trying to find the sourcecode for Kotlin Native, and I can't even find that method it is crashing on. So if anyone has any ideas would really help me out? I have a relatively simple module I have just created, and for whatever reason it wont build
    m
    • 2
    • 6
  • f

    Francis Mariano

    02/11/2021, 6:01 PM
    Hello guys. I have a BluetoothRepository which is responsible to emit a SharedFlow. I have also a DeviceScanPresenter which is responsible for collecting the emitted data by BluetoothRepository. However, the data is emitted with success, but the DeviceScanPresenter does not collect the data. Note: This code works like a charm on ANDROID device. The problem described above happens just on iOS device. Can anyone give a tip about the problem? DeviceScanPresenter
    class DeviceScanPresenter(
        private val bluetoothRepository: BluetoothRepositoryKmm
    ) : BasePresenter<DeviceScanView>() {
    
        private val mainScope = MainScope()
        private var scan: Job? = null
    
        .......
    
        fun deviceScanDevice() {
            view?.log("presenter - deviceScanDevice444")
            view?.showCancelButton()
            view?.clearDevices()
            view?.log("presenter - deviceScanDevice:beforeOfLaunch")
            scan = mainScope.launch(start = CoroutineStart.UNDISPATCHED) {
                view?.log("presenter - deviceScanDevice:launch")
                try {
                    view?.log("presenter - deviceScanDevice:try")
                    withTimeout(20000) {
                        view?.log("presenter - deviceScanDevice:withTimeout:withTimeout")
                        view?.log("presenter - deviceScanDevice:withTimeout:bluetoothRepository = $bluetoothRepository")
                        bluetoothRepository.devices.collect {
                            view?.log("presenter - deviceScanDevice:withTimeout:collect")
                            view?.showDevice(it)
                        }
                    }
                } catch (e: TimeoutCancellationException) {
                    view?.log("presenter - deviceScanDevice:catch : ${e.message}")
                    view?.showUpdateButton()
                }
            }.apply {
                invokeOnCompletion {
                    bluetoothRepository.stopScanLeDevice()
                    view?.log("presenter - deviceScanDevice444:invokeOnCompletation")
                }
            }
            view?.log("presenter - deviceScanDevice:startScanLeDevice")
            bluetoothRepository.startScanLeDevice()
        }
        
        .....
    }
    BluetoothRepositoryKmm
    object BluetoothRepositoryKmmImpl : BluetoothRepositoryKmm {
    
        ....
    
        private var repositoryScope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
    
        ....
    
        private val _devices = MutableSharedFlow<Device>()
        override val devices = _devices.asSharedFlow()
    
        ....
    
        override fun startScanLeDevice() {
            println("BluetoothRepositoryKmmImpl - startScanLeDevice333")
            scanJob = repositoryScope.launch {
                println("BluetoothRepositoryKmmImpl - startScanLeDevice:launch")
                Scanner().advertisements.collect {
                    println("BluetoothRepositoryKmmImpl - startScanLeDevice:collect")
                    val ret = _devices.tryEmit(it.devicePlatformFrom())
                    println("BluetoothRepositoryKmmImpl - startScanLeDevice:collect:ret = $ret")
                }
            }.apply { invokeOnCompletion { println("BluetoothRepositoryKmmImpl - startScanLeDevice:invokeOnCompletation") } }
        }
    
        ....
    
    }
    • 1
    • 2
  • d

    dasralph

    02/12/2021, 11:17 AM
    Hello, after updating to Kotlin 1.4.30, IntelliJ has problems with my Kotlin multiplatform modules. This blue dot on the modules is gone, and also code highlighting isn’t working anymore :-( I only change the used Kotlin version from 1.4.21 to 1.4.30. I use IntelliJ IDEA 2020.3.2, and all IntelliJ plugins are up to date. Do I have to do more than just changing the Kotlin version?
    b
    m
    • 3
    • 11
  • b

    Benoît

    02/12/2021, 12:38 PM
    Hey guys, I'm getting this after doing some refactoring. Android compiles but iOS gives me this error
    e: Compilation failed: Backend Internal error: Exception during IR lowering
    File being compiled: /Users/benoit/dev/project/business-logic/src/commonMain/kotlin/com/project/business_logic/BusinessLogicModule.kt
    The root cause java.lang.IllegalArgumentException was thrown at: org.jetbrains.kotlin.backend.common.lower.SingleAbstractMethodLowering.createObjectProxy(SingleAbstractMethodLowering.kt:393)
    
     * Source files:
     * Compiler version info: Konan: 1.4.30 / Kotlin: 1.4.30
     * Output kind: FRAMEWORK
    
    e: org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
    File being compiled: /Users/benoit/dev/project/business-logic/src/commonMain/kotlin/com/project/business_logic/BusinessLogicModule.kt
    The root cause java.lang.IllegalArgumentException was thrown at: org.jetbrains.kotlin.backend.common.lower.SingleAbstractMethodLowering.createObjectProxy(SingleAbstractMethodLowering.kt:393)
            at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException(CodegenUtil.kt:239)
            at org.jetbrains.kotlin.backend.common.CodegenUtil.reportBackendException$default(CodegenUtil.kt:235)
    
    
    ...
    
    
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
            at java.lang.Thread.run(Thread.java:748)
    Caused by: java.lang.IllegalArgumentException: Sequence contains more than one matching element.
            at org.jetbrains.kotlin.backend.common.lower.SingleAbstractMethodLowering.createObjectProxy(SingleAbstractMethodLowering.kt:393)
            at org.jetbrains.kotlin.backend.common.lower.SingleAbstractMethodLowering.visitTypeOperator(SingleAbstractMethodLowering.kt:122)
            at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitTypeOperator(IrElementTransformerVoid.kt:245)
    Any idea ?
    ✅ 1
    • 1
    • 1
  • p

    Paul Woitaschek

    02/12/2021, 3:13 PM
    I'm trying to figure out for hours how to prevent my app building the watchos modules when using
    .gradlew publish
    . I tried to disable all publish tasks that contain watchos but it still builds the targets
    a
    • 2
    • 1
  • k

    kpgalligan

    02/14/2021, 3:16 PM
    Running into issues with the hierarchical source set config and linux platforms (from mac). I can build code from the command line on my local machine, but Intellij does not recognize "platform.xxx" dependencies for linux source sets, and running in CI (Github actions) fails in the same place as the IDE. I don't know why they will build locally, running the same gradle command as CI does. The CI build fails on trying to compile the source set metadata.
    compile[source set name]MainKotlinMetadata
    . If there isn't an obvious issue and setting I should apply that somebody knows offhand, I'll post a simple example a bit later. I'm thinking if I could just set something that tells gradle to ignore non-native hosts, and config CI to also build with a linux host, I might be able to move forward (CI currently runs mac and windows builds). Thoughts?
    r
    a
    +3
    • 6
    • 43
  • a

    Abhishek Dewan

    02/15/2021, 6:24 AM
    Hi all, does anyone know if the KMM plugin is compatible with Android Studio Arctic Fox | 2020.3.1 Canary 5 Build #AI-203.6682.168.2031.7101492, built on January 25, 2021
    j
    • 2
    • 3
  • a

    Alex Anisimov

    02/15/2021, 9:33 AM
    Hi everyone! We know that when it comes to using Kotlin technologies the best innovations come from you, our community! Do you have any tips or tricks for building cross-platform applications with KMM? We’d love to know them! Share your greatest tips with the community by replying to this message. We will feature the best tips on our Twitter along with a shout out to the author.
    👀 7
    b
    d
    +2
    • 5
    • 21
  • g

    gammax

    02/15/2021, 10:39 AM
    Hey all 👋 Do we have a multiplatform oss project that is publishing to
    mavenCentral
    and using the
    maven-publish
    plugin (no 3rd parties)? If yes don’t you mind linking 🙏
    j
    r
    +4
    • 7
    • 79
  • a

    aiidziis

    02/15/2021, 12:47 PM
    Hey!  Has anyone managed to publish multiplatform library as a Pod to private GitLab repository? Currently we are using
    pod ‘MobileEngine, :path => ‘../MobileEngine’
    , but we would like to version our library and distribute it to private repository. Haven’t found any useful blog/article/repository.
    j
    • 2
    • 4
  • i

    Ivan Fedyanin

    02/15/2021, 2:05 PM
    Hello, I think initially I put the question in wrong channel, so copying it here! Can anyone recommend an approach for using websockets on iOS in kotlin multiplatform? I have read this thread and question, but I could not find a solution there. Is it possible to use websockets written in kotlin multiplatform in iOS ? My goal is to have a library which can be iused on JVM, Android and iOS. With JVM and Adnroid it seems to be not a problem, but the iOS is an open question
    a
    c
    e
    • 4
    • 5
  • b

    bmo

    02/15/2021, 3:26 PM
    Hello, I'm sorry if this question has been asked before but I couldn't find an answer (either on the web or here). I understand that iOS and MacOS source sets can only be compiled from a Mac for legal reasons (Apple being Apple...) Yet, I'm on Linux and I would like to be able to contribute to the iOS code (even if not compiling) but when I sync a project with a pod dependency, I cannot import the dependencies and I see this in the command line :
    > Task :module:podGenIOS SKIPPED
    > Task :module:podSetupBuildPodDependencyIphonesimulator SKIPPED
    I suspend this is linked to me not being able to see the dependencies. Is there a way for me to force Kotlin to generate the bridge (or at least let IntelliJ know about it) so that I can develop for iOS in Kotlin MPP without actually buying a Mac ?
    a
    • 2
    • 6
  • a

    Amritansh

    02/15/2021, 4:04 PM
    Hello, I am running it an issue when trying to build from terminal
    Unresolved reference: newSingleThreadContext
    . The project builds and run fine if I use Android studio or xcode to run the app. These are all the dependencies which I am using
    object Versions {
    
        const val MIN_SDK = 23
        const val COMPILE_SDK = 30
        const val TARGET_SDK = 30
    
        const val kotlin = "1.4.20"
    
        const val androidTools = "4.1.1"
    
        const val coroutines = "1.3.9-native-mt-2"
    
        const val serialization = "1.0.1"
    
        const val ktor = "1.4.3"
    
        const val klock = "2.0.0"
    
        const val benasherUUID = "0.2.3"
    
        const val stately = "1.1.0"
    
        const val junit = "4.12"
    
        const val sqlDelight = "1.4.3"
    }
    
    object Dependencies {
        const val kotlinGradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}"
        const val kotlinSerialization = "org.jetbrains.kotlin:kotlin-serialization:${Versions.kotlin}"
        const val androidTools = "com.android.tools.build:gradle:${Versions.androidTools}"
        const val coroutinesCore =
            "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.coroutines}"
        const val kotlinxSerialization =
            "org.jetbrains.kotlinx:kotlinx-serialization-core:${Versions.serialization}"
        const val ktorClientCore = "io.ktor:ktor-client-core:${Versions.ktor}"
        const val ktorClientSerialization = "io.ktor:ktor-client-serialization:${Versions.ktor}"
        const val ktorClientAndroid = "io.ktor:ktor-client-android:${Versions.ktor}"
        const val ktorClientIos = "io.ktor:ktor-client-ios:${Versions.ktor}"
        const val klock = "com.soywiz.korlibs.klock:klock:${Versions.klock}"
        const val benasherUUID = "com.benasher44:uuid:${Versions.benasherUUID}"
        const val stately = "co.touchlab:stately-concurrency:${Versions.stately}"
        const val junit = "junit:junit:${Versions.junit}"
        const val sqlDelightGradlePlugin =
            "com.squareup.sqldelight:gradle-plugin:${Versions.sqlDelight}"
        const val sqlDelightCommon = "com.squareup.sqldelight:runtime:${Versions.sqlDelight}"
        const val sqlDelightAndroid =
            "com.squareup.sqldelight:android-driver:${Versions.sqlDelight}"
        const val sqlDelightIOS =
            "com.squareup.sqldelight:native-driver:${Versions.sqlDelight}"
    }
    r
    • 2
    • 5
  • a

    Abhishek Dewan

    02/16/2021, 6:26 AM
    Hi all, I am trying to follow the KampKit project to setup my own and I am running into some issues with Kermit and specifically, the NsLogLogger class. My build gradle is below, when I go to try to use the NsLogLogger class with Kermit it can’t find it. AFAIK there doesn’t seem to be a discernible difference between my gradle and the one in KamptKit. Any ideas would be appreciated. P.S I am able to the iOS library in my external libraries but it just doesn’t find the class 😞
    import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
    
    plugins {
        kotlin("multiplatform")
        id("com.android.library")
        id("kotlinx-serialization")
    }
    
    kotlin {
        android()
        ios {
            binaries {
                framework {
                    baseName = "shared"
                    isStatic = false
                    export(Deps.kermit)
                    transitiveExport = true
                }
            }
        }
    
        sourceSets {
    
            all {
                languageSettings.apply {
                    useExperimentalAnnotation("kotlin.RequiresOptIn")
                    useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
                }
            }
    
            val commonMain by getting {
                dependencies {
                    implementation(kotlin("stdlib-common"))
                    implementation(Deps.Ktor.commonCore)
                    implementation(Deps.Ktor.commonJson)
                    implementation(Deps.Ktor.commonLogging)
                    implementation(Deps.Coroutines.common) {
                        version {
                            strictly(Versions.coroutines)
                        }
                    }
                    implementation(Deps.multiplatformSettings)
                    implementation(Deps.koinCore)
                    implementation(Deps.Ktor.commonSerialization)
                    implementation(Deps.kotlinxDateTime)
                    api(Deps.kermit)
                }
            }
            val commonTest by getting {
                dependencies {
                    implementation(kotlin("test-common"))
                    implementation(kotlin("test-annotations-common"))
                }
            }
            val androidMain by getting {
                dependencies {
                    implementation("com.google.android.material:material:1.2.1")
                }
            }
            val androidTest by getting {
                dependencies {
                    implementation(kotlin("test-junit"))
                    implementation("junit:junit:4.13")
                }
            }
            val iosMain by getting {
                dependencies {
                    implementation(Deps.Ktor.ios)
                }
            }
            val iosTest by getting
        }
    }
    
    android {
        compileSdkVersion(29)
        sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
        defaultConfig {
            minSdkVersion(24)
            targetSdkVersion(29)
        }
    }
    
    val packForXcode by tasks.creating(Sync::class) {
        group = "build"
        val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
        val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
        val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
        val framework = kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
        inputs.property("mode", mode)
        dependsOn(framework.linkTask)
        val targetDir = File(buildDir, "xcode-frameworks")
        from({ framework.outputDirectory })
        into(targetDir)
    }
    
    tasks.getByName("build").dependsOn(packForXcode)
    r
    • 2
    • 2
  • j

    Jawid

    02/16/2021, 1:25 PM
    Hello everyone, I am not able to create a file object inside the classes in the shared KMM library, does anyone how to do that or why?
    r
    • 2
    • 1
  • m

    mbonnin

    02/16/2021, 4:45 PM
    Updating to Kotlin 1.4.30, I get
    Execution failed for task 'publishKotlinMultiplatformPublicationToMavenLocal'.
    > Failed to publish publication 'kotlinMultiplatform' to repository 'mavenLocal'
       > Invalid publication 'kotlinMultiplatform': multiple artifacts with the identical extension and classifier ('jar', 'sources').
    Does that ring any bell?
    n
    • 2
    • 3
  • b

    Ben Lancaster

    02/16/2021, 4:51 PM
    Hi friends. I’m working on a long-standing Kotlin Multiplatform project at the moment with Android Mobile + Android TV + iOS + tvOS targets. We’re in the process of migrating to the Gradle Kotlin DSL but running in to some problems with how to migrate away from
    fromPreset
    for our use case. Can anyone give me a steer on what I should be using instead? Example in the thread:
    • 1
    • 1
  • d

    Dean Djermanović

    02/16/2021, 4:54 PM
    Any ideas how to fix this?
    w
    f
    • 3
    • 6
  • f

    Francis Mariano

    02/16/2021, 6:49 PM
    Can anyone to indicate to me a repository with samples of native-mt coroutines?
    s
    • 2
    • 1
  • r

    robstoll

    02/16/2021, 7:30 PM
    sad to see, that
    synchronized
    will go away from common (
    Synchronization on any object is not supported on every platform and will be removed from the common standard library soon.
    ). Is there another locking mechanism available?
    b
    a
    • 3
    • 4
  • n

    Neal Sanche

    02/16/2021, 10:00 PM
    Hi All, before I give this a try, does anyone know if a KMM module can have a dependency on another KMM module in the same project? I've come up against a set of plugins that seem to be incompatible with each other (moko-network, apollo graphql) and was thinking that if I could split the moko-network dependency into a separate module, that might solve my issues. Any idea?
    m
    • 2
    • 16
  • a

    Abhishek Dewan

    02/17/2021, 1:06 AM
    I am trying to write a simple POC where I try to inject an implementation of an interface into iOS and Android. I have the koin dependency defined like shown. In android I can inject using the way I shown below and in iOS I am using the way I have shown below but the iOS one fails and the error it throws is not very useful to determine what’s going on. The Koin.get extension functions that are provided in Kampkit are present in my project as well. Anyone have an idea on how I can achieve this?
    • 1
    • 4
  • s

    Slackbot

    02/17/2021, 6:44 PM
    This message was deleted.
    m
    d
    • 3
    • 9
  • d

    Daniele B

    02/18/2021, 6:06 PM
    Is everyone using Ktor Client on CommonMain having the same warning?
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.
    c
    • 2
    • 2
  • p

    Patrick Ramsey

    02/18/2021, 8:17 PM
    Hi, folks! I’m trying to add a commonTest sourceset to a kmp project that already has android, ios, and js build targets. A questions: When I try to run my newly minted unit test on the js target, I’m seeing “Could not determine the dependencies of task “:<project name>:jsTestPackageJson: NPM Dependencies already resolved and installed”. Digging around in the gradle source, it looks like this might indicate that the KotlinPackageJsonTask is running at the wrong time (ie, an assertion is failing). Has anyone else encountered this? Just confirmed that it’s happening for jsTest as well (just hadn’t noticed since it’s not currently wired into our CI). Thanks in advance for any clarity you might have to offer!
    • 1
    • 4
  • m

    Mustafa Ozhan

    02/18/2021, 9:09 PM
    Hello guys 👋 I just shared an article (my first one 🙂) It is about, how to deal with secret keys\urls in Kotlin Multi Platform projects. I had problems with it and spend time to find solution I hope it will help also for the people looking for answers 🙂 Feedbacks are more than welcome https://mustafaozhan.medium.com/gracefully-dealing-with-private-keys-in-kotlin-multi-platform-e9d21d62ad2a
    🙌 1
    🔥 1
    a
    • 2
    • 1
  • n

    Neal Sanche

    02/18/2021, 9:20 PM
    Today I ran into an issue with the
    iosX64test
    target on a project where the test (only one test, as a proof of concept) previously passed. After adding a second KMP module (to work around a conflict between two gradle plugins), the ios tests now hang indefinitely with what looks like a gradle daemon connection issue. Thing is, the second module doesn't contain any tests, it is just code generation. Now the tests just repeat the following over and over:
    2021-02-18T14:17:06.271-0700 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire shared lock on daemon addresses registry.
    2021-02-18T14:17:06.271-0700 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired on daemon addresses registry.
    2021-02-18T14:17:06.271-0700 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
    The way that I included the second KMP module was using a dependency entry:
    commonMainApi(project(":shared-rest"))
    I'm not sure what I should try to get the tests to finish as expected. Any ideas?
    • 1
    • 1
  • d

    Denis Ismailaj

    02/18/2021, 11:49 PM
    Cross-posting here since this is the bigger channel.
    n
    k
    • 3
    • 4
  • v

    Vinod Rai

    02/19/2021, 6:56 AM
    Hi All, 1. There is a requirement in my KMM project to use the existing database file in common code using SQLDelight like the .db file we use from assets in android. how I can do this? 2. I wish to access the JSON text from the file stored locally, parse it & return in the response in case of Network/API failure. Is there any way to do this? Thanks in advance!
    m
    • 2
    • 3
Powered by Linen
Title
v

Vinod Rai

02/19/2021, 6:56 AM
Hi All, 1. There is a requirement in my KMM project to use the existing database file in common code using SQLDelight like the .db file we use from assets in android. how I can do this? 2. I wish to access the JSON text from the file stored locally, parse it & return in the response in case of Network/API failure. Is there any way to do this? Thanks in advance!
m

Mustafa Ozhan

02/19/2021, 8:16 AM
Hello, I had same issue I couldn’t find an solution, but I found a work around, If your database is not so huge you can open your asset with sqllitebrowser and then you can export the neccessary tables as blabla.sqlite then you will be able to add
INSERT INTO
commands like here https://github.com/CurrencyConverterCalculator/CCC/blob/master/common/src/commonMain/database/com/github/mustafaozhan/ccc/common/sql/Currency.sq
v

Vinod Rai

02/19/2021, 11:43 AM
Thanks, but I have 1000 or more records in table
m

Mustafa Ozhan

02/19/2021, 12:43 PM
I see.. please let me know also if you find something, I would like to change my implementation too if possible 🙂
View count: 9