https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
multiplatform
  • s

    Stephen Gazzard

    04/29/2021, 7:59 PM
    Those using KMM for iOS development - how have you worked with / around these errors?
    Exception doesn't match @Throws-specified class list and thus 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: com.apollographql.apollo.ApolloNetworkException: Failed to execute GraphQL http network request
    Seems a built in part of the KMM framework is if your Kotlin function doesn’t mark @Throws() with the exception, KMM crashes your app. There’s no compile time safety enforcing that only exceptions annotated in @Throws, so it is possible that an exception is missed that later ends up crashing your iOS application. This is undesired behaviour, as if we miss documenting an exception, it can crash in the wild. In iOS, we typically just show an error message when an unexpected error arises. Is there a way to ensure that Kotlin never crashes us in this case?
    m
    • 2
    • 3
  • j

    Jeff Tycz

    04/30/2021, 1:02 AM
    In my KMP project I am trying to sort a HashMap by its keys, however I noticed that
    toSortedMap
    seems not to be available in the common module only the JVM. What is the way to sort a hashmap in the common module?
    e
    • 2
    • 10
  • r

    Rita Okonkwo

    04/30/2021, 7:45 AM
    Hello everyone, I am working with KMM & KTOR to post data to an API. However , when the post request is successful, it returns a set of API-specific headers. I am supposed to use one of the header information to make another request. So , I made the POST request to return an HttpResponse. However, AS shows this error when trying to make the post request in my main activity in android studio. Please any idea on how I can fix it? Thank you
    t
    m
    c
    • 4
    • 15
  • a

    Alex Anisimov

    04/30/2021, 4:22 PM
    Hi everyone 👋, The KMM team is keen to improve our documentation, and right now we are working on improving documentation dedicated to Objective-C interoperability. Please help us make it better by taking part in a short survey. Feel free to DM me in case you have any questions. Here is the link to the survey.
    👋 6
    b
    • 2
    • 1
  • r

    rocketraman

    04/30/2021, 9:06 PM
    When building a multiplatform app for Android, I notice that I have two
    mapping.txt
    files -- one in the
    shared
    build, and one in the Android app build. However, the Play store only accepts one file. Does the Android one contain all the necessary information from
    shared
    ?
    s
    • 2
    • 1
  • s

    Saiedmomen

    04/30/2021, 9:11 PM
    How can you share test util code between multiplatform modules? Should I put it in main sourceset?
    :yes: 2
    b
    t
    • 3
    • 2
  • k

    KD

    04/30/2021, 10:07 PM
    Hey guys 👋🏻,are there any good resources you’d recommend to get started with kotlin native? (Besides official Kotlin docs). Thank you!
    x
    n
    • 3
    • 3
  • c

    Christian Gaisl

    05/02/2021, 7:03 PM
    Hi, I’m building a multiplatform app and I have run into an issue in iOS regarding SwiftUI preview not working at all. I’ve boiled the issue down to the following minimum working example: I’m using an Android Studio KMM template project with the iOS framework distribution set to the CocoaPods dependency manager. When use a class that has the member-parameter syntax (I don’t know how it’s called? i mean “testString” in the following example code) in a View, the preview crashes. An example for such a class would be:
    //Does not work with SwiftUI preview
    class Greeting1(
        var testString: String
    ) {
        fun greeting(): String {
            return "Hello, ${Platform().platform}!"
        }
    }
    
    //Works with SwiftUI preview
    class Greeting2(
        testString: String
    ) {
        fun greeting(): String {
            return "Hello, ${Platform().platform}!"
        }
    }
    An instance of this class being part of the view, even if none of its members are actually displayed, crashes the preview. It works fine on the simulator though. This does not happen in the template project when using the Xcode build phases framework approach, the one with the packForXcode task. Does anyone have any idea what could cause this?
    x
    j
    v
    • 4
    • 12
  • j

    José González Gómez

    05/03/2021, 11:35 AM
    Can you use shared resources for tests in a Kotlin Multiplatform Mobile project? I tried to include some JSON files under
    src/commonTest/resources
    but they don't seem to get copied to the output directory when running Android tests. Putting them under
    src/androidTest/resources
    did the trick for Android tests, but I don't want to have two copies of these files, as they are common for both Android and iOS tests.
    👀 2
    d
    n
    +2
    • 5
    • 10
  • j

    jmfayard

    05/03/2021, 1:00 PM
    Is there a Kotlin Multiplatform library to work with files? a simple wrapper to
    java.util.File
    on the JVM and POSIX calls on Kotlin native
    fopen
    ,
    fclose
    ,
    acccess
    , ...
    e
    j
    +3
    • 6
    • 8
  • x

    xxfast

    05/04/2021, 1:15 AM
    Anyone figured a nicer way to consume a stateflow from swift side?
    m
    • 2
    • 1
  • f

    Fabio Santo

    05/04/2021, 6:38 AM
    Hello everyone 👋 is anyone interested in joining a Kotlin multiplatform project for a new app? I'm looking for teammates 🙂 Tech stack is the ideal : Kotlin multiplatform + SwiftUI + Compose + GraphQL. Sydney or Australia based only 🇦🇺
    j
    • 2
    • 2
  • r

    rb90

    05/04/2021, 10:33 AM
    Hi, I have a question on kotlin multiplatform and memory management for ios and I am very grateful if someone has an hint for me here. When using classes from a kotlin multiplatform shared module in an ios app (f.e. in a local function context in a view controller) - when this view controller gets removed from memory the kotlin multiplatform sdk classes still continue living in the memory. Is there a way to also remove them from there? Is that a known issue?
    ✅ 1
    m
    l
    s
    • 4
    • 40
  • j

    Jozef Matus

    05/04/2021, 12:53 PM
    Hi did anybody succeed with resuming 
    suspendCoroutine
     from another thread? Im getting
    CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation
    l
    • 2
    • 1
  • y

    Yusuf

    05/04/2021, 2:12 PM
    Hi folks! I've written an article about intercepting network calls using KMM/Ktor and throwing custom exceptions (it turned to be pretty tricky topic), it might help some of you too. Here's the link: https://yusufabd.medium.com/kotlin-multiplatform-mobile-intercepting-network-request-and-response-6805a79b4699
    👍 2
    a
    • 2
    • 1
  • j

    José González Gómez

    05/04/2021, 2:22 PM
    Has anybody faced problems when including resources in the
    androidTest
    source set?? I'm getting this:
    Warning:project ':xxx': Unable to build Kotlin project configuration
    Details: org.gradle.api.InvalidUserDataException: Source directory '/Users/xxx/Documents/projects/xxx/src/androidTest/resources/provider-metadata.json' is not a directory.
    when reloading the Gradle project in Android Studio. I've tried putting the file both in the root
    androidTest/resources
    directory and in a nested folder under that directory. If I do the following it works properly: 1. Remove any files under
    androidTest/resources
    2. Reload the Gradle project in Android Studio 3. Move/copy files to
    androidTest/resources
    4. Run tests to my heart's content without any problem using existing Android Studio's Run/Debug configuration I can also run
    ./gradlew build
    or
    ./gradlew test
    without any problem with files located under
    androidTest/resources
    ... I've even tried to re-create the Android Studio project deleting the
    .idea
    folder and re-opening the project... what am I doing wrong????
    t
    • 2
    • 5
  • j

    Jeremias Nunez

    05/04/2021, 2:55 PM
    Hi! I'm trying to add an extension to ByteArray that converts it to NSData, following this snippet: https://gist.github.com/noahsark769/61cfb7a8b7231e2069a9dab94cf74a62. I've added a new file with the extension in the iosMain module, but I cannot see it in the iOS code. What am a I missing?
    m
    • 2
    • 7
  • v

    Vitor Prado

    05/04/2021, 3:06 PM
    There is a way to write things to apple keychain directly from kotlin?
    r
    • 2
    • 2
  • j

    Josh

    05/04/2021, 5:18 PM
    Hey 👋 Im a student whos new to kotlin multiplatform. I am builing a KMM app and was wondering if anyone has used any projects that allow for shared view models in KMM
    v
    • 2
    • 17
  • c

    chi

    05/04/2021, 8:02 PM
    With KMM still in Alpha, how do you convince a team that doesn't use Alpha libraries that KMM's alpha is different from the average alpha framework? (not just pointing them to other big team companies that has KMM in production). More like, how reliable is KMM's alpha state?
    u
    s
    • 3
    • 3
  • v

    Vitor Prado

    05/04/2021, 9:17 PM
    what do you all think about save tokens in ios userdefaults?? i saw a lot of devs yelling about how it’s unsafe.. but it’s like sharedprefs on android.. i know it’s not encrypted, but you need access to devices filesystem to read it.. correct me if i am wrong: you need to hack the device or stole the device to have access to it. (and after that you need to understand what it is and how to use)
    m
    s
    +4
    • 7
    • 14
  • d

    darkmoon_uk

    05/05/2021, 2:17 AM
    While it's an early soft-release (what the customer themselves termed 'Pre-MVP'), I'm proud to say my team successfully launched our Kotlin Multiplatform App to the store today! :kotlin: 💪 📱 BarnTalk for iOS on the AppStore :android:  BarnTalk for Android on Google Play
    🎉 4
    👏🏼 1
    👏 1
    a
    • 2
    • 2
  • m

    Mikhail Buzuverov

    05/05/2021, 4:59 AM
    Hello! Is there library for mocking common code? I have some classes in common code and I would like to write unit tests, so I need to mock their dependencies. Which library is suitable for that?
    d
    d
    • 3
    • 11
  • m

    Michal Klimczak

    05/05/2021, 6:23 AM
    I'm slowly losing my mind over Android Studio Canary 15. Suddenly (it worked fine for a few days and then stopped) it went rogue with indexing and I can't fix it. I tried every trick in the book including removing android studio, restarting computer, removing AS settings etc. Everything from here as well: https://kotlinlang.slack.com/archives/CRDCFF3RC/p1618779620052500 Project builds just fine, it's just that Android studio doesn't index most classes, including very basic ones like platform.Foundation or any external libraries. It stopped marking the right directories as sources root like you see in the screenshot. I can mark them manually, but it doesn't fix the issue with indexing libraries or
    platform.*
    etc. I guess the problem is with it not properly collecting sources, but how do I fix it?
    i
    r
    • 3
    • 13
  • b

    Berkan

    05/05/2021, 2:55 PM
    Is there a website that explains the KMM architecture in an UML way? I want to know for example if Dependency Inversion is used with the shared module and ios/android specific implementation in the source sets
    m
    • 2
    • 2
  • j

    jmfayard

    05/05/2021, 7:01 PM
    Hello, I am currently trying to assemble a starter project for people who want to write command-line tools in Kotlin multiplatform. I would appreciate if you can have a look and tell me what you think Thanks! 🙏🏻 https://github.com/jmfayard/kotlin-cli-starter
    c
    l
    j
    • 4
    • 10
  • s

    sushma nayak

    05/05/2021, 8:22 PM
    Hi Foks, I’m getting
    kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen
    exception.
    Dependencies info -
    kotlin = "1.4.30"
    coroutines = "1.4.2-native-mt"
    serialization = "1.0.1"
    ktor = "1.4.2"
    This is what I’m doing -
    class Manager {
     var user: User
     init(){
      GlobalScope.async(context = Dispatchers.Default) {
      val result = callToSuspendFunction
      user = result //ERROR ON THIS LINE
     }
    }
    How to achieve something like this?
    u
    v
    k
    • 4
    • 4
  • n

    Napa Ram

    05/06/2021, 5:35 AM
    Hi Forks, I'm exploring KMM, I have done with the setup in Android Studio. I could able to run the Android app perfectly, but when I try to run the ios app, facing an issue in configuration setup. Xcode project scheme Dropdown is empty. • But when I launch the ios App directly from Xcode, the app is working perfectly.
    r
    • 2
    • 4
  • a

    Andyeshiet

    05/06/2021, 8:35 AM
    I am trying to replace
    packForXcode
    with the
    cocoapods
    approach, everything runs fine on the android, but i get an error while trying to build for ios. Error shown ☝️
    r
    • 2
    • 2
  • n

    Napa Ram

    05/06/2021, 9:58 AM
    Hi Fork, is there any documentation how iOS code we are writing in kotlin in shared module inside iosApp module when it come specific to Platfrom if i want to access camera or filemanager then what will be the process to put in common module
    r
    • 2
    • 2
Powered by Linen
Title
n

Napa Ram

05/06/2021, 9:58 AM
Hi Fork, is there any documentation how iOS code we are writing in kotlin in shared module inside iosApp module when it come specific to Platfrom if i want to access camera or filemanager then what will be the process to put in common module
r

Róbert Nagy

05/06/2021, 10:07 AM
You should be able to pull in dependencies with cocoapods into the iOS/Apple sourcets and then use them. NSFramework dependencies should be importable by default AFAIK
• See cocoapods integration • An example of how to import the UIKit and build on that
View count: 11