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

    Lucas Schiavini

    03/28/2022, 8:26 PM
    Has anyone had problems finding common kotlin classes on the android sourceset?
    m
    r
    • 3
    • 4
  • l

    Lucas Schiavini

    03/28/2022, 8:27 PM
    Like: shared: androidMain -> can't find anything from commonMain here! commonMain
    m
    • 2
    • 1
  • n

    nikhil kumar

    03/29/2022, 11:02 AM
    Hey, Has anyone tried to serialize Map<String, Any> ?
    g
    h
    • 3
    • 5
  • v

    Vladimir Malykhin

    03/30/2022, 10:12 AM
    Hi everyone, I migrate to Kotlin 1.6.10 and after when compile iOS project by Xcode get error
    Task :commonModule:linkDebugFrameworkIosArm64 FAILED
    e: Compilation failed: Symbol for kotlin.time/Duration.toComponents|2397542651005564009[0] is unbound Has anyone ever met with such a thing?
    a
    • 2
    • 6
  • r

    rsetkus

    03/30/2022, 3:14 PM
    Hi. I am trying to build a kmm project which uses
    SQLCipher
    but getting error.
    Exception in thread "main" java.lang.Error: /var/folders/z3/gtgsk6493gz1yqt86nzbgnyh0000gn/T/17166564073649352201.m:1:9: fatal error: could not build module 'SQLCipher'
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':xxx:cinteropSQLCipherIosX64'.
    Any ideas how to fix this?
    d
    • 2
    • 4
  • a

    Akram Bensalem

    03/30/2022, 10:58 PM
    Hello! How to set up Decompose for iOS part in Cocoapods ?
    i
    a
    • 3
    • 4
  • v

    vishal G

    03/31/2022, 5:53 AM
    How to have a base url in build.gradle in KMM shared
    g
    • 2
    • 6
  • r

    Raymond Chan

    04/01/2022, 10:19 AM
    Hello everyone, has any of you encountered this issue for iOS project on CI? My issue is like this, Gradle execution failed on CI for iOS project, which Android’s SDK doesn’t exist, as the CI image is for iOS build only.
    * What went wrong:
    A problem occurred configuring project ':ninegag-shared-lib'.
    > Could not create task ':ninegag-shared-lib:lint'.
       > SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Users/distiller/project/under9-shared-kmm/local.properties'
    Is it possible to bypass this
    :lint
    task creation? And also there is an interesting part,
    ./gradlew
    execution failed with above error for the first run, where it tries to download Gradle wrapper. Once the
    ~/.gradle
    cache is created, if I call
    ./gradlew
    again, it success without the above error. It only happens when
    gradlew
    is being downloaded for the first time.
    • 1
    • 2
  • a

    afonso

    04/01/2022, 1:41 PM
    👋 everyone! I’m looking for architectural best practices when it comes to KMM. I did a quick search in the channel but came up short. Here’s my situation: I have an existing iOS app and I’m trying out KMM. Ideally, the new version of the app. with KMM, would be available both for Android and iOS, but for the existing iOS users it would be an under the hood change, they wouldn’t lose any of their current content. I started building a
    MigratorService
    in
    iosMain
    , including all the necessary platform-specific models. I had to implement these models because I wanted to take this opportunity to revisit all the existing models and improve their structure which makes the native models not match 1-1 with the new ones. But now I’m at a crossroads since I have no way to call the
    MigratorService
    from
    commonMain
    . So I either: • Move all the code I’ve done in
    iosMain
    to
    commonMain
    . This has the potential risk of exposing old iOS related code to Android and the potential scenario where an Android app might try to run the migration. It also makes code ergonomics a bit more complicated, since I have a
    User
    common model and an old
    User
    iOS model. • Create an expect
    MigratorService
    in commonMain, with the actual implementation being on
    iosMain
    . But this approach implies also adding a complete
    no-op
    version of
    MigratorService
    in
    androidMain
    . Which is exposing an API that doesn’t really do what is expected. Which one would be considered the best practice in KMM and why? Or is there another alternative to tackle these situations?
    k
    • 2
    • 10
  • g

    grahamborland

    04/01/2022, 5:06 PM
    Dumb question. Why are some of these source directories bold with a blue dot, and some aren’t?
    🙌 1
    j
    l
    • 3
    • 5
  • s

    Slackbot

    04/02/2022, 11:11 AM
    This message was deleted.
    m
    • 2
    • 1
  • v

    vishal G

    04/02/2022, 11:19 AM
    hi folks!! I need to store my apikeys securely in my KMM project which can be used both by android and ios code how to do that in shared module in kmm?
    p
    s
    • 3
    • 4
  • d

    Dragos Rachieru

    04/04/2022, 11:44 AM
    Hello, does anyone know what I did wrong here? Is this a bug? Code in thread
    g
    • 2
    • 9
  • l

    Lucas Schiavini

    04/04/2022, 3:24 PM
    Anyone has experience building a common module with android and ios kotlin database implementations?
    k
    h
    c
    • 4
    • 11
  • r

    Robert Jaros

    04/05/2022, 5:04 AM
    After upgrade to 1.6.20 the
    compileKotlinMetadata
    or
    metadataMainClasses
    gradle tasks don't work anymore (don't try to compile
    common
    sources or even create a
    build
    directory). What has changed?
    a
    • 2
    • 2
  • m

    Michael Bichlmeier

    04/05/2022, 6:48 AM
    Hi, is someone able to support me by accessing values from my
    local.properties
    inside my common code base? I need credentials (each dev has its own) to send an REST request. I did in local.properties:
    username=myName
    password=myPassword
    I have no idea how I can access them, in my code. In my
    build.gradle
    I can do something like that:
    val userName: String = gradleLocalProperties(rootDir).getProperty("username")
    val password: String = gradleLocalProperties(rootDir).getProperty("password")
    But how can I connect the gradle variables into my code? Do I miss some imports or something similar?
    g
    • 2
    • 6
  • a

    Anton Lakotka [JB]

    04/05/2022, 9:00 AM
    Hi! With 1.6.20 release we have enabled HMPP by default https://kotlinlang.org/docs/whatsnew1620.html#hierarchical-structure-support-for-multiplatform-projects 🎉 Please share your feedback!
    🎉 4
    :thumbsup_all: 1
    👍 3
    m
    • 2
    • 3
  • j

    Jose Garcia

    04/05/2022, 10:38 AM
    Hi, we are using the M1 chips for our development and therefore using your
    1.6.20-M1
    release. When we run
    ./gradlew assemble
    on our machines, everything works fine. However, when we run it on our CI we get the following log. Our CI is using
    gradle:jdk-11
    docker image which is linux-aarc64 based. Does anyone know what's going on? It seems that
    1.6.20-M1
    can't be used on non macOS systems? If so, is there a way to use
    1.6.20-M1
    and
    1.6.20
    simultaneously?
    e
    • 2
    • 11
  • a

    Andrew O Hart

    04/05/2022, 10:43 AM
    Hey all, was wondering if anybody could help. We have a prod app using SQLDelight. I need to create a new Table that will hold a date. The dates going to be sent as a param for a server call. So we need to check if the date exists in this new Table, if not, use the current date, and store it. I was wondering how best to do this? As I believe we will need a database migration. I'm also not sure of the best way to create the Table. I have added it to my .sq file, but when I try to check if there is any date in it, I get 'no such table' error, which makes sense as it hasn't been created. I'm not sure of where the best place to create it would be. Any ideas?
    e
    • 2
    • 2
  • a

    alec

    04/05/2022, 3:05 PM
    I've got a KMM library module, and then an app with a common module that depends on it. For whatever reason the common module doesn't resolve sources in the library module, but only for the
    compileCommonMainKotlinMetadata
    task, like theres no source set for metadata. The metadata stuff always confuses me, wondering if anyone has seen this too and knows whats up. It's only happening in the 1.6.20 upgrade and my suspicion is it has to do with HMPP but I'm not sure
    ➕ 1
    r
    r
    m
    • 4
    • 9
  • r

    Rachel Carandang

    04/05/2022, 3:17 PM
    I recently switched my Kotlin Multiplatform Android coroutines library from org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2-native-mt to 1.6.0 which I thought solved the threading issues in 1.5.x. However, now my iOS app, which consumes the Multiplatform library, is crashing on the first occurrence of a coroutine being launched (stack trace below). The code causing the crash is below. What is a resolution to this issue?
    // in Kotlin Multiplatform library
    DeviceSource {
        override fun start() {
            testDevices
                .onEach { list ->
                    list.devices.forEach { addKnownDevice(it) }
                }
                .launchIn(Dispatchers.Main)
        }
    Exception:
    at 0   test                            0x10c51f388        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 88 
      at 1   test                            0x10c519286        kfun:kotlin.Exception#<init>(kotlin.String?){} + 86 
      at 2   test                            0x10c519476        kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 86 
      at 3   test                            0x10c5199c6        kfun:kotlin.IllegalStateException#<init>(kotlin.String?){} + 86 
      at 4   test                            0x10c6aab54        kfun:kotlinx.coroutines.takeEventLoop#internal + 388 
      at 5   test                            0x10c6aad03        kfun:kotlinx.coroutines.OldDefaultExecutor#dispatch(kotlin.coroutines.CoroutineContext;kotlinx.coroutines.Runnable){} + 179 
      at 6   test                            0x10c6ab211        kfun:kotlinx.coroutines.OldMainDispatcher#dispatch(kotlin.coroutines.CoroutineContext;kotlinx.coroutines.Runnable){} + 241 
      at 7   test                            0x10c68e783        kfun:kotlinx.coroutines.internal#resumeCancellableWith__at__kotlin.coroutines.Continuation<0:0>(kotlin.Result<0:0>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?){0§<kotlin.Any?>} + 1091 
      at 8   test                            0x10c69e37b        kfun:kotlinx.coroutines.intrinsics#startCoroutineCancellable__at__kotlin.coroutines.SuspendFunction1<0:0,0:1>(0:0;kotlin.coroutines.Continuation<0:1>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?){0§<kotlin.Any?>;1§<kotlin.Any?>} + 603 
      at 9   test                            0x10c69e57d        kfun:kotlinx.coroutines.intrinsics#startCoroutineCancellable$default__at__kotlin.coroutines.SuspendFunction1<0:0,0:1>(0:0;kotlin.coroutines.Continuation<0:1>;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?;kotlin.Int){0§<kotlin.Any?>;1§<kotlin.Any?>} + 333 
      at 10  test                            0x10c624883        kfun:kotlinx.coroutines.CoroutineStart#invoke(kotlin.coroutines.SuspendFunction1<0:0,0:1>;0:0;kotlin.coroutines.Continuation<0:1>){0§<kotlin.Any?>;1§<kotlin.Any?>} + 323 
      at 11  test                            0x10c613edc        kfun:kotlinx.coroutines.AbstractCoroutine#start(kotlinx.coroutines.CoroutineStart;0:0;kotlin.coroutines.SuspendFunction1<0:0,1:0>){0§<kotlin.Any?>} + 156 
      at 12  test                            0x10c614139        kfun:kotlinx.coroutines#launch__at__kotlinx.coroutines.CoroutineScope(kotlin.coroutines.CoroutineContext;kotlinx.coroutines.CoroutineStart;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,kotlin.Unit>){}kotlinx.coroutines.Job + 585 
      at 13  test                            0x10c614452        kfun:kotlinx.coroutines#launch$default__at__kotlinx.coroutines.CoroutineScope(kotlin.coroutines.CoroutineContext?;kotlinx.coroutines.CoroutineStart?;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,kotlin.Unit>;kotlin.Int){}kotlinx.coroutines.Job + 626 
      at 14  test                            0x10c688823        kfun:kotlinx.coroutines.flow#launchIn__at__kotlinx.coroutines.flow.Flow<0:0>(kotlinx.coroutines.CoroutineScope){0§<kotlin.Any?>}kotlinx.coroutines.Job + 275 
      at 15  test                            0x10c45672b        kfun:com.testlabs.testshared.device.DeviceSourceImpl#start(){} + 539 
      at 16  test                            0x10c4e206b        objc2kotlin.1302 + 139 
      at 17  test                            0x10c2940cf        $s8test19MultiplatformConfigO5startyyFZ + 95 (/Users/rachelcarandang/dev/test/Config/MultiplatformConfig.swift:48:42)
      at 18  test                            0x10c0999ff        $s8test9AppConfigO5startyyFZ + 47 (/Users/rachelcarandang/dev/test/Config/AppConfig.swift:46:29)
      at 19  test                            0x10c2c5941        $s8test11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtF + 1057 (/Users/rachelcarandang/dev/test/test/AppDelegate.swift:40:19)
      at 20  test                            0x10c2c6096        $s8test11AppDelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0j6LaunchI3KeyaypGSgtFTo + 182 
      at 21  UIKitCore                           0x7fff25055f2e     -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 215 
      at 22  UIKitCore                           0x7fff25057b9e     -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 4114 
      at 23  UIKitCore                           0x7fff2505d50d     -[UIApplication _runWithMainScene:transitionContext:completion:] + 1220 
      at 24  UIKitCore                           0x7fff245d9c79     -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 121
    m
    a
    • 3
    • 5
  • t

    Tarek Salama

    04/05/2022, 9:07 PM
    Hello, I am working on an iOS project and my colleagues created a KMM library to share some code and I managed to integrate it via a framework file (planning on putting it into a Swift Package later on). The main issue I have is that I can't get autocomplete in Xcode to work properly with it. I have some methods and classes that get autocompleted and some that never do. For the ones that don't; I have to look at the objective c header files, try my best to match it and then hope that it compiles. It's really a painful and time consuming process. Any idea where I could start troubleshooting? EDIT: The framework xcframework file was created using
    ./gradlew createSwiftPackage
    👀 1
    m
    • 2
    • 2
  • a

    Adam S

    04/06/2022, 8:05 AM
    Hi, is there a multiplatform way of capturing stdout from
    println(...)
    ? I'm writing unit tests using Knit, and I want to verify the output is the same on as many platforms as possible. Ideally at least JS and JVM. Here's one of the tests. Kotest has
    captureStandardOut(...)
    , but it's JVM only
    • 1
    • 1
  • c

    clhols

    04/06/2022, 10:03 AM
    When trying to run a KMM iOS app from AppCode on an iPhone 13 simulator I get this in idea.log: Caused by: com.intellij.execution.ExecutionException: Unable To Install “Test” Failed to get FD to bundle executable at /Users/user/Library/Developer/CoreSimulator/Devices/83507766-1C3A-411B-807B-DB39447FCF06/data/Library/Caches/com.apple.mobile.installd.staging/temp.WuhDKR/extracted/Test.app/Test at com.jetbrains.cidr.execution.simulatorSupport.SimulatorProcessHandler.getException(SimulatorProcessHandler.java:437) ... 8 more
    d
    v
    • 3
    • 10
  • r

    Ruslan Iusupov

    04/06/2022, 11:00 AM
    Hi guys! I've got two iOS projects: main (production project which has been existing for years) and test (simple project which you can get from Xcode wizard). And I've got multimodule KMM project. When I add KMM umbrella framework to the main project via cocoapods, for some reason it creates the framework with different name from name it links. In test project it works as expected. You can find my cocoapods configuration in the thread. For the main project it creates
    domain_facade
    framework, but links
    MyDomainLogic
    . For the test project as expected creates
    MyDomainLogic
    framework and links
    MyDomainLogic
    . My current workaround is just setting
    cocoapods.name
    and
    framework.baseName
    to
    domain_facade
    . Also in the main project I get strange runtime exception
    kotlin.ClassCastException: kotlin.String cannot be cast to kotlin.String
    . It happens in
    co.touchlab.sqliter.DatabaseFileContext.kt
    on line 39 https://github.com/touchlab/SQLiter/blob/286784f503f414efd88679362ddac47222b7110f/sqliter-driver/src/appleMain/kotlin/co/touchlab/sqliter/DatabaseFileContext.kt#L39 Again in the test project works without problems. Do you have any ideas?
    r
    • 2
    • 2
  • a

    Anthony Martin

    04/06/2022, 3:36 PM
    Hey all, Is it possible to load a WASM in a web browser for various platforms with a Kotlin MPP project?
    e
    l
    • 3
    • 3
  • a

    Anthony Martin

    04/06/2022, 3:37 PM
    We are looking into a new application and looking at React Native vs Kotlin MPP with Compose. We have an android app already with Compose which can easily be converted to Kotlin MPP (It’s pure android right now). So if we can get WASM working within Kotlin then we should be more towards using Kotlin MPP - Thanks
    s
    • 2
    • 1
  • i

    iamsteveholmes

    04/06/2022, 4:05 PM
    [SOLVED] Anyone else experiencing
    unresolved reference
    problems in Android Studio or Intellij for Kotlin 1.6.20? I filed a seemingly related issue months ago that was never resolved and it appears to be happening by default in 1.6.20. https://youtrack.jetbrains.com/issue/KT-48148 EDIT: This appears to have been an issue with my settings. I had to install a new intellij without importing settings. I’m working with support to pinpoint the issue.
    r
    a
    • 3
    • 6
  • j

    Jurriaan Mous

    04/06/2022, 7:44 PM
    I have an issue with the hierarchical project structure together with cinterop. I have switched to use a
    darwinMain
    shared sourceSet and platform specific cinterop implementations. It all works well to run
    macosArm64Test
    tasks and succeeds with all building and tests. But as soon I want to publish my library it wants to run
    compileDarwinMainKotlinMetadata
    it fails with the following exception failing to find cinterop based code which is only present in specific implementations:
    > Task :compileDarwinMainKotlinMetadata FAILED
    e: /Users/jurmous/space/rocksdb-multiplatform/src/appleMain/kotlin/maryk/rocksdb/AbstractComparator.kt: (5, 8): Unresolved reference: rocksdb
    The build.gradle.kts setup I use: https://github.com/marykdb/rocksdb-multiplatform/blob/master/build.gradle.kts Project can be checked out and build but macOS is needed. What am I missing so publishing completes successfully? And is publishing the metadata of that shared darwinMain sourceSet needed?
    m
    a
    • 3
    • 4
  • x

    xxfast

    04/07/2022, 3:35 AM
    Hmm, im surprised that this is allowed.
    // commonMain
    expect class Pager
    
    // androidMain
    actual typealias Pager = PagerState
    Feels weird that you can expect a class and have it actualised by a type alias
    a
    • 2
    • 2
Powered by Linen
Title
x

xxfast

04/07/2022, 3:35 AM
Hmm, im surprised that this is allowed.
// commonMain
expect class Pager

// androidMain
actual typealias Pager = PagerState
Feels weird that you can expect a class and have it actualised by a type alias
a

Anton Lakotka [JB]

04/07/2022, 6:57 AM
Perhaps my explanation of how expect/actual works might help you understand that it is not. 1. Typealias by its definition creates no new types. It is just a syntax sugar that declares a new name for some type expression. 2. Think about expects as some kind of Forward declaration . But Kotlin makes it stricter to ensure 1-to-1 relation between expects and actuals during compilation time. Basically expect declaration is a prototype of some Kotlin class or function. And compiler verifies that all usages of that prototype is possible when compiling a platform classes/binaries. Lets look at your example:
// commonMain.kt
expect class Pager

fun foo(pager: Pager) { println(pager) }

// androidMain.kt
actual typealias Pager = PagerState
When compilation for android is requested through
./gradlew build
for example. Kotlin compiler will receive as input both source files. roughly like this:
kotlinc src/commonMain.kt src/androidMain.kt
Compiler will scan all files and will try to match all expects and actuals. And if its all right, it internally makes your code look like this:
// internal representation
fun foo(pager: Pager) { println(pager) }
typealias Pager = PagerState
this is perfectly valid code. Hope this helps you to understand the logic behind expect/actual.
👍 1
x

xxfast

04/21/2022, 5:00 AM
that actually makes sense. Thanks for the explanation @Anton Lakotka [JB]
View count: 22