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

    Rak

    06/16/2021, 7:52 AM
    Can someone explain what this means:
    implementation(kotlin("test-common"))
    I understand the original gradle format well but I am finding information on the new kts format lacking
    c
    • 2
    • 5
  • n

    Napa Ram

    06/16/2021, 8:15 AM
    Hi Everyone whenever i fetch the data firstName is coming always as empty but while debuging it is saving can anyone explain this
    class PersonaldetailsLocalDatasource() {
    
        private val realm: Realm by lazy {
            val configuration = RealmConfiguration(schema = setOf(PersonaldetailsDao::class))
            Realm.open(configuration)
        }
    
        private var _personalDetailsObserver= MutableStateFlow<PersonaldetailsDao>(PersonaldetailsDao())
        val personalDetailsObserver = _personalDetailsObserver.asStateFlow()
    
    
        fun storePersonalDetail(personaldetailsDao: PersonaldetailsDao){
            realm.writeBlocking {
                copyToRealm(PersonaldetailsDao().apply {
                    firstName = personaldetailsDao.firstName
                })
            }
    
        }
        fun fetchData(): StateFlow<PersonaldetailsDao> {
            realm.objects(PersonaldetailsDao::class)
            realm.objects(PersonaldetailsDao::class).observe {
                _personalDetailsObserver.value = it[0]
            }
            return personalDetailsObserver
        }
    }
    • 1
    • 2
  • j

    John O'Reilly

    06/16/2021, 9:50 AM
    might be worth asking in #realm channel
    n
    • 2
    • 10
  • t

    Tiago Nunes

    06/16/2021, 10:22 AM
    Hey everyone, I've created a KMM library (with Android and ios targets) using the cocoapods plugin. This library imports an Obj C library via pod. The library compiles, and cinteropsObjCLibraryIos task works great. Then I create another KMM project, and import the library project (in settings.gradle) and add the dependency to commonMain (
    implement(project(":myLibrary"))
    ). When I sync and build for Android, everything works great, I even get code completion in iosMain. But when I run for iOS, I get this error:
    Task :MyLibrary:cinteropObjCLibraryIos FAILED
    Exception in thread "main" java.lang.Error: /var/folders/26/l5zqw1v936l866mn2pwdy2j00000gn/T/7243334423362035241.m:1:9: fatal error: module 'ObjCLibrary' not found
    Any ideas? I've been stuck for hours...
    c
    o
    • 3
    • 21
  • c

    Colton Idle

    06/16/2021, 1:35 PM
    iOS noob: Which directory do I open in xcode to do development in that IDE?
    v
    t
    • 3
    • 2
  • b

    Bailey Pollard

    06/16/2021, 1:40 PM
    Hey folks, currently in the process of following this guide to implement a cocoapods dependancy, but keep getting this error when I build. Am I missing a step that was skipped in the documentation?
    v
    t
    • 3
    • 46
  • s

    spierce7

    06/16/2021, 3:14 PM
    Does anyone have an M1 Mac that they can comment on the coding experience with Kotlin Multiplatform?
    c
    e
    s
    • 4
    • 10
  • y

    Yashar

    06/16/2021, 4:53 PM
    Hey all, I am currently stuck with this error on task
    :shared:linkDebugFrameworkIos
    when trying to build iOS. Has anyone encountered this before?
    Task :shared:linkDebugFrameworkIos FAILED
    e: Compilation failed: /Users/user/.konan/kotlin-native-prebuilt-macos-1.5.20-RC/konan/nativelib/2514903830371359478/libllvmstubs.dylib: dlopen(/Users/user/.konan/kotlin-native-prebuilt-macos-1.5.20-RC/konan/nativelib/2514903830371359478/libllvmstubs.dylib, 1): no suitable image found.  Did find:
    	/Users/user/.konan/kotlin-native-prebuilt-macos-1.5.20-RC/konan/nativelib/2514903830371359478/libllvmstubs.dylib: mach-o, but wrong architecture
    	/Users/user/.konan/kotlin-native-prebuilt-macos-1.5.20-RC/konan/nativelib/2514903830371359478/libllvmstubs.dylib: mach-o, but wrong architecture
    
     * Source files: 
     * Compiler version info: Konan: 1.5.20-RC / Kotlin: 1.5.20
     * Output kind: FRAMEWORK
    
    e: java.lang.UnsatisfiedLinkError: /Users/user/.konan/kotlin-native-prebuilt-macos-1.5.20-RC/konan/nativelib/2514903830371359478/libllvmstubs.dylib: dlopen(/Users/user/.konan/kotlin-native-prebuilt-macos-1.5.20-RC/konan/nativelib/2514903830371359478/libllvmstubs.dylib, 1): no suitable image found.  Did find:
    	/Users/user/.konan/kotlin-native-prebuilt-macos-1.5.20-RC/konan/nativelib/2514903830371359478/libllvmstubs.dylib: mach-o, but wrong architecture
    	/Users/user/.konan/kotlin-native-prebuilt-macos-1.5.20-RC/konan/nativelib/2514903830371359478/libllvmstubs.dylib: mach-o, but wrong architecture
    • 1
    • 1
  • s

    spierce7

    06/16/2021, 6:11 PM
    Does anyone know how to fix the kmm error when trying to build from Android Studio -
    Error: Invalid XcProject file
    ?
    k
    h
    • 3
    • 2
  • a

    Alberto

    06/16/2021, 11:12 PM
    how do we access Java collection APIs like
    Queue
    in Kotlin Multiplatform?
    e
    i
    c
    • 4
    • 7
  • c

    Colton Idle

    06/17/2021, 2:30 AM
    Does anyone use the KMM plugin in AS, hit run for ios, and then a simulator apparently starts, but the window isn't visible anywhere?
    ➕ 1
    a
    s
    t
    • 4
    • 4
  • s

    Stefan Oltmann

    06/17/2021, 7:21 AM
    Did anyone figure out how to configure JaCoCo in a KMM project? It started with the Compose for Desktop Template (from the Wizard), but it does not seem possible to activate JaCoCo if also the "android-library" plugin is applied. So is there no way to report code coverage to sonarqube via gradle in Multiplatform projects?
    r
    k
    +2
    • 5
    • 24
  • n

    Nikiizvorski

    06/17/2021, 9:52 AM
    Hey guys anyone available to give me some tips about a complex migration that i have? Thanks
    a
    c
    • 3
    • 21
  • r

    Rak

    06/17/2021, 10:06 AM
    I came across an article talking about the concurrency model and it talks about freeze(). I tried to run the code but the IDE does not recognise the freeze() method. What am I doing wrong? https://play.kotlinlang.org/hands-on/Kotlin%20Native%20Concurrency/02_Frozen
    t
    • 2
    • 44
  • n

    Nikiizvorski

    06/17/2021, 2:51 PM
    Hey guys i need to use Lock and implementation(“org.jetbrains.kotlin:kotlin-stdlib-common”) but IOS compains in my project any tips? Is it supported on IOS
    b
    c
    • 3
    • 7
  • b

    Bailey Pollard

    06/17/2021, 6:43 PM
    Is anyone able to attempt to import the pod:
    pod("StarIO", "~> 2.8.2")
    And let me know if it succeeds for you?
    j
    • 2
    • 28
  • r

    Rak

    06/17/2021, 9:55 PM
    I am following the sample project that JetBrains have - the sample code is here https://github.com/KaterinaPetrova/kmm-ktor-sample It works after updating some dependencies. Look at this code here:
    class Greeting {
        private val httpClient = httpClient() {
            install(Logging) {
                level = LogLevel.HEADERS
                logger = object : Logger {
                    override fun log(message: String) {
                        Napier.v(tag = "HTTP Client", message = message)
                    }
                }
            }
            install(JsonFeature) {
                val json = Json { ignoreUnknownKeys = true }
                serializer = KotlinxSerializer(json)
            }
        }.also { initLogger() }
    
        @Throws(Throwable::class)
        suspend fun greeting(): String {
            return "${getHello().random().string}, ${Platform().platform}! X"
        }
    
        private suspend fun getHello(): List<Hello> {
            return httpClient.get("<https://gitcdn.link/cdn/KaterinaPetrova/greeting/7d47a42fc8d28820387ac7f4aaf36d69e434adc1/greetings.json>")
        }
    }
    I knew I wanted to do some json manipulation so I made the Json instance an instance variable:
    class Greeting {
        private val json = Json { ignoreUnknownKeys = true }
        private val httpClient = httpClient() {
            install(Logging) {
                level = LogLevel.HEADERS
                logger = object : Logger {
                    override fun log(message: String) {
                        Napier.v(tag = "HTTP Client", message = message)
                    }
                }
            }
            install(JsonFeature) {
                serializer = KotlinxSerializer(json)
            }
        }.also { initLogger() }
    
        @Throws(Throwable::class)
        suspend fun greeting(): String {
            return "${getHello().random().string}, ${Platform().platform}! X"
        }
    
        private suspend fun getHello(): List<Hello> {
            return httpClient.get("<https://gitcdn.link/cdn/KaterinaPetrova/greeting/7d47a42fc8d28820387ac7f4aaf36d69e434adc1/greetings.json>")
        }
    }
    and now iOS crashes with an error:
    Function doesn't have or inherit @Throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError.
    It is considered unexpected and unhandled instead. Program will be terminated.
    Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen com.jetbrains.kmmktor2.Greeting@3dbf5e8
    Anyone know why?
    l
    a
    • 3
    • 2
  • d

    darkmoon_uk

    06/18/2021, 5:22 AM
    Hi @Joe Birch , I was following your nice article on using Firebase Authentication from KMP; but noticed you had subsequently removed the
    FirebaseAuthentication
    module and related files from your project on GitHub. I'm interested in building the same capability into my App; so I wanted to ask why that was - did you encounter a problem using the Firebase REST API's in this way? Thanks.
    t
    • 2
    • 2
  • e

    Ethan Hsu

    06/18/2021, 6:35 AM
    For all of the CocoaPods + Kotlin Multiplatform fans out there here is a very helpful resource. Often times, some CocoaPods dependencies won't resolve properly due to some interop issues. However, if you export your pods using CocoaPods Rome and then import them as frameworks... it may work: https://github.com/CocoaPods/Rome
    • 1
    • 1
  • r

    Rak

    06/18/2021, 10:23 AM
    Anyone else seeing the need to compile and deploy twice before the iOS project picks up changes in shared?
    b
    • 2
    • 12
  • j

    Jack W

    06/18/2021, 1:40 PM
    Hey everyone! This is my first time using Slack and I am also a beginner with Kotlin, so let me know if this question should go somewhere else. My question is: is Kotlin/Native for iOS “safe” to get started with given the memory management redesign? I am confused about whether or not code will have to be rewritten for Kotlin Multiplatform Libraries/modules once the iOS memory management redesign is released. Thanks!
    r
    k
    • 3
    • 3
  • g

    Guilherme Delgado

    06/18/2021, 4:31 PM
    Hi guys, have you noticed an increase of .apk size? A simple app with 4 screens (UI in compose) exports an .apk with size of ~45mb while iOS 4mb. Have the table been turned? 😛
    l
    • 2
    • 10
  • a

    Abhishek Dewan

    06/19/2021, 7:00 AM
    I was reading through this post by @John O'Reilly and was wondering if there is a genuine reason you would have both cocoapods and swift package publishing for your iOS app? (Android developer here trying his hand out on iOS so pardon the lack of knowledge on my part)
    j
    c
    s
    • 4
    • 5
  • b

    Big Chungus

    06/19/2021, 1:39 PM
    is it possible to publish MPP artefact with no sources? My use-case is a "marker" artefact that declares dependencies on all library modules to make it easy to get them all via transitive dependencies.
    r
    l
    • 3
    • 20
  • e

    Elka

    06/20/2021, 7:15 AM
    Kotlin Native: Why are
    implementation
    dependencies specified in submodules are exported when
    transitiveExport = true
    ? Shouldn’t it only export dependencies marked with
    api
    ?
    c
    l
    • 3
    • 5
  • h

    Hossein Amini

    06/20/2021, 8:51 AM
    In KMM projects, is it possible to check internet connection with Ktor? I want to write my code in shared module and use in both iOS and Android platforms #ktor
    r
    a
    • 3
    • 2
  • b

    Bailey Pollard

    06/20/2021, 7:59 PM
    Hey folks, wondering if there is any way to eliminate the need for duplicated code in both iosX64Main/iosArm64Main directories? Tried to find some documentation on this with no luck
    m
    a
    +2
    • 5
    • 13
  • s

    saket

    06/21/2021, 2:55 AM
    I can’t seem to be able to suppress compiler warnings against
    kotlin.time
    APIs. I already have this in my buildscript as mentioned in the docs:
    kotlin {
      sourceSets {
        all {
          languageSettings.apply {
            useExperimentalAnnotation("kotlin.RequiresOptIn")
            useExperimentalAnnotation("kotlin.time.ExperimentalTime")
          }
        }
    }
    am I missing something?
    r
    e
    • 3
    • 3
  • a

    Alex

    06/21/2021, 7:46 AM
    Not sure if anyone else has hit this problem, I have a bunch of
    enum
    classes in the shared module that I'm trying to use in a
    Picker
    in iOS. I had no issues using the enums in Android, but the
    Picker
    in SwiftUI requires the class to conform to
    CaseIterable
    and
    RawRepresentable
    . This hits a bit of a brick wall because you can only implement the
    RawRepresentable
    interface within the source class and not in an extension, has anyone found a way around this or do you have to create two enum classes and map between them?
    👀 1
    o
    • 2
    • 3
  • s

    Stefan Oltmann

    06/21/2021, 9:47 AM
    I'm looking for a Kotlin Multiplatform library that also allows to write EXIF data. Does anyone know a good one? I need something that runs on JVM Desktop, Android and iOS. I'm aware that Kotlin/Native allows me to use the built-in libs from Android & iOS, but I'm not sure what to do about Desktop... expect that I could use Apache Commons Imaging. A pure Kotlin EXIF Reader/Writer would be a nice thing, but I don't find one so far.
    ✅ 1
    b
    • 2
    • 4
Powered by Linen
Title
s

Stefan Oltmann

06/21/2021, 9:47 AM
I'm looking for a Kotlin Multiplatform library that also allows to write EXIF data. Does anyone know a good one? I need something that runs on JVM Desktop, Android and iOS. I'm aware that Kotlin/Native allows me to use the built-in libs from Android & iOS, but I'm not sure what to do about Desktop... expect that I could use Apache Commons Imaging. A pure Kotlin EXIF Reader/Writer would be a nice thing, but I don't find one so far.
✅ 1
b

Big Chungus

06/21/2021, 9:56 AM
You might try your luck on kamp.petuska.dev, although I doubt such solution exists.
s

Stefan Oltmann

06/21/2021, 9:58 AM
Thanks. No search results for "exif" 😕
b

Big Chungus

06/21/2021, 9:58 AM
Then there's nothing for it on mavenCentral I'm affraid
s

Stefan Oltmann

06/21/2021, 9:59 AM
Thanks. I bookmarked the site anyway 🙂
View count: 16