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

    oday

    10/08/2022, 8:22 PM
    does this step mentioned in the tutorial not happen anymore since time of writing? https://play.kotlinlang.org/hands-on/Networking%20and%20Data%20Storage%20with%20Kotlin[…]om%20Mobile/05_Configuring_SQLDelight_an_implementing_cache
    When the project is compiled, the generated Kotlin code will be stored in the
    /shared/build/generated/sqldelight
    directory. The generator will create an interface with the named
    AppDatabase
    , as we specified in
    build.gradle.kts
    this is right after implementing
    AppDatabase.sq
    with SQLDelight
    • 1
    • 5
  • s

    spierce7

    10/09/2022, 4:11 PM
    Do platforms besides JVM currently use the K2 Compiler?
    e
    • 2
    • 1
  • r

    Robert Munro

    10/10/2022, 12:04 PM
    i have a sealed class in mu kotlin usecase but the types arent available in iOS - just wondering if there is anything i have to do to get the sealed subclasses to be generated (compiler flag or something?). The module is
    domainKmm
    class LoginUseCase {
    sealed class State {
        object Initial : State()
        object StartAuthorization : State()
        object AuthorizationTokenReceived : State()
        object AccessTokenReceived : State()
        object SuppliersLoading : State()
        data class SuppliersLoaded(val suppliers: List<Supplier>) : State()
        data class ConfirmSupplierChange(val chosenSupplier: Supplier, val currentSupplier: Supplier) : State()
        data class SupplierLoadError(val e: Throwable) : State()
        object NoSupplier : State()
        data class LoggedInSuccess(val isNewSupplier: Boolean) : State()
    }
    }
    So i can use
    DomainKmmLoginUseCase
    and
    DomainKmmLoginUseCase.State
    but i cant use
    DomainKmmLoginUseCase.State.Initial
    I cant find any declaration of things like
    Initial
    or
    StartAuthorization
    in the generated iOS header file. is there any guidance on using sealed classes in iOS? i've seen they dont really map to swift well - but havent been able to find any usage examples.
    n
    • 2
    • 13
  • a

    Alejandro Rios

    10/10/2022, 3:42 PM
    Yes
    t
    r
    +3
    • 6
    • 6
  • s

    spierce7

    10/10/2022, 4:40 PM
    Has anyone seen any benchmarks around the new memory manager for Kotlin/native? I’m curious how well it’s performing now
    m
    • 2
    • 4
  • n

    no

    10/10/2022, 4:54 PM
    I'm running a test with Kotlin Multiplatform and I see the following message in the logs. What does it mean?
    :arrow-optics:compileKotlinIosX64	
    Invalid device: iPhone 12	
    Invalid device: iPhone 12	
    Invalid device: iPhone 12
    Does it mean that I have an iPhone 12 connected but I require some other version? Does it mean that it is looking for an iPhone 12 but couldn't find it?
    m
    j
    • 3
    • 6
  • i

    itnoles

    10/11/2022, 3:19 AM
    on https://kotlinlang.org/docs/multiplatform-mobile-plugin-releases.html#release-details, 0.3.4 = Beta?
  • d

    Daniele B

    10/11/2022, 10:48 AM
    There is something I don't get about the Jetpack Multiplatform libraries: If DataStore depends on Java IO and Android platform APIs, how can it be multiplatform? https://android-developers.googleblog.com/2022/10/announcing-experimental-preview-of-jetpack-multiplatform-libraries.html?m=1
    t
    v
    +5
    • 8
    • 15
  • c

    colintheshots

    10/11/2022, 9:08 PM
    I have a project to develop a shared KMM library module. However, it needs to use both Sqldelight and Ktor, which are also used by our main shared common code module for the app. How can I use the same Sqlight and Ktor dependencies for both multiplatform library iOS frameworks and not duplicate the dependencies?
    k
    n
    m
    • 4
    • 6
  • j

    Justin Xu

    10/12/2022, 2:59 AM
    Hi all, right now I have a kmm mobile app and a ktor server project in separate repositories that I want to combine, but when I put ktor in a jvmMain source set I get
    The 'java' plugin has been applied, but it is not compatible with the Android plugins.
    . Is there a better way to have a single client/server app in kmm mobile?
    v
    m
    • 3
    • 6
  • d

    darkmoon_uk

    10/12/2022, 5:49 AM
    ⚠️ 🙅 It appears that Cocoapods integration is effectively broken when using Cocoapods version >=
    1.11.0
    , due to the arbitrary decision from Cocoapods to make it a hard requirement to have a
    LANG
    environment variable set. • Here is a tracking issue in Cocoapods repo, requesting this requirement be stepped-back • I've also raised a :youtrack: YouTrack issue to hopefully restore compatibility with latest Cocoapods.
    • 1
    • 1
  • p

    Pablo

    10/12/2022, 9:08 AM
    Hi, google recently announced that they have added DataStore and Collections libraries into kotlin multiplatform. They have added them to Jetpack Multiplatform. Those libraries depends on java: • Collections is an example of a library written in the Java programming language that has no Android-specific dependencies, but implements Java collection APIs. • DataStore is written entirely in Kotlin, and it uses coroutines in both its implementation and APIs. It also depends on Java IO and Android platform APIs. Now that these libraries can be used in kotlin multiplatform, does that means that they have been ported to kotlin native removing java dependency and that they can be used to develop a IOS or Windows native project without a JVM installed?
    b
    z
    • 3
    • 5
  • t

    Tower Guidev2

    10/12/2022, 9:13 AM
    Hi, i am a native android developer looking for a solution to consuming C# (.NET dlls) within a Kotlin/Java Andrid application i have spent the last few days searching the internet for solutions such as Embeddinator-4000, DNNE Java.Interop without success I was wondering (hoping) KMM would allow/support this usecase, can anyone confirm (Or deny 😉 ) KMM is the answer I am looking for please?
  • s

    Seb Jachec

    10/12/2022, 1:59 PM
    Hi, is anyone else getting a lot of warnings in their iOS build after updating from Kotlin 1.7.10 to 1.7.20? In both Xcode 14.0 & 14.1b3, simulator or device, our build is totally cluttered with over 3,000 warnings in the format
    (arm64) could not find object file symbol for symbol ...
    after changing version. Seems like most relate to iOS code written in Kotlin, or 3rd party dependencies (Okio, SQLDelight, Koin, Apollo, NSExceptionKt).
    r
    i
    +2
    • 5
    • 20
  • n

    Neil

    10/12/2022, 3:46 PM
    Is there a KMM lib or pattern to abstract Android's
    Service
    and the iOS equivalent to keep an app running in the background with UI closed?
    k
    s
    • 3
    • 3
  • l

    Lucas

    10/13/2022, 1:11 AM
    Is there any way to anotate a class in common module with java-only lib anotations? expected/actual didnt work because the anotation has enum inside and i couldnt get it to work
    v
    b
    +2
    • 5
    • 26
  • g

    Gellért Biró

    10/13/2022, 9:18 AM
    Is there any way to import some iOS network specific classes like
    platform.Network.NWConnection
    to an
    actual
    Kotlin class? I can see classes like
    platform.Network.nw_connection_t
    but I am not sure they are the same.
    s
    • 2
    • 2
  • e

    elect

    10/13/2022, 10:38 AM
    I'd like to nest some tests, ie
    class DesignControllerTest {
        @Nested
        inner class DeleteDesign {
            @Test
            fun `design is removed from db`() {}
        }
    }
    but
    @Nested
    isn't available, it looks like it requires Junit5. However, JUnit is for JVM only, or? Is there a way to nest test for all platforms?
  • n

    Natalia

    10/13/2022, 2:47 PM
    Hello , question about KMM and swift framework. I wanted to integrate it in Shared module. Doing so by docs https://kotlinlang.org/docsmultiplatform-mobile-ios-dependencies.html results in error module not found. Did someone had the same and how to resolve this? Maybe someone have Open source sample ?
    h
    • 2
    • 5
  • t

    tylerwilson

    10/13/2022, 4:34 PM
    Similar question to above: I have tried to wrap the KMM generated xcframework in a Swift Package, plus some Swift code as wrappers to make the API more 'Swift-y'. But I am unable to get the Package.swift configured just right. It would be great to see an example of this, if possible. Or if not possible, would be nice to know that too.
  • k

    Kieren Searle

    10/13/2022, 7:32 PM
    Hello, I'm trying to compile a c++ static lib and link it to my cinterops compilation. I've managed to compile the c++ lib using cpp-library, but I can't think of how to link the output to the inputs of cinterops. Anyone have any ideas on how to do this, or if I'm doing something completely wrong?
    b
    l
    • 3
    • 27
  • i

    Isaac Akakpo

    10/13/2022, 10:38 PM
    Migrated my KMM Currency Convertor App from using multi-platform settings to the new Jetpack Datastore Preview. Seems like nothing was changed and was trivial. :] . Check it out here https://github.com/develNerd/FL-CurrencyConvertor-Kotlin-Multiplatform-Mobile .
  • e

    elect

    10/14/2022, 3:43 AM
    in case anyone is interested, I just finally found out how to bind gradle code generation task properly at the
    build
    task:
    tasks {
        val generateCode by registering(GenerateCode::class)
        kotlin.sourceSets.commonMain { kotlin.srcDir(generateCode.get().outputs.files) }
    e
    • 2
    • 4
  • j

    Joey

    10/14/2022, 1:40 PM
    In my multiplatform project I'm using the following build phase script code to automatically upload dSyms to crashlytics
    "${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
    This works fine in xCode, but in Android studio it points to my git repo that contains the project code, whereas xCode properly defines that as the directory in the derivedData. Is this perhaps an issue with how KMM builds the project when ran from Android Studio? As that for some reason $BUILD_DIR seems to have a different value when ran from the KMM build
    • 1
    • 1
  • j

    Joey

    10/14/2022, 2:12 PM
    Did you manage to solve this? I'm currently facing the same problem
    s
    s
    • 3
    • 4
  • s

    shahroz

    10/15/2022, 2:25 PM
    Hey folks, I have got some questions and would love to hear your thoughts on this. We have developed two native SDKs (android and iOS) in our company. And since there is alot of same business logic, I was thinking of creating a library(maybe multiplatform?) with ability to publish maven and cocopods artifacts. That way we will still have two native SDKs but code will be the shared. Wanted to clarify few things. 1- Does this sound like a good approach? 2- Can multiplatform library has separate aritifacts for native SDKS? 3- Would it significantly increase the size of SDKs? 4- Would our host app be required to add external dependencies of any sort? e.g Multiplatform etc? 5- Anything else, I should worry about? Any kind of help would be highly appreciate. I have tried looking for similar use cases if anyone else is doing but couldn't find any.
    j
    k
    v
    • 4
    • 10
  • b

    Blake Anderson

    10/16/2022, 8:12 PM
    I'm having a lot of difficulty getting @JsExport to work reliably. I have a separate KotlinJs project where it seems okay, but within a multiplatform project the behavior appears inconsistent. From my testing here's the most I know: • At the root level, @JsExport doesn't do anything. However,
    main
    is always exported regardless. • Within a package, @JsExport works as expected (making sure any identifiers included are not mangled). However, any function not referenced is not included. Functions that are referenced at the root level but not themselves exposed (likely because they aren't referenced?) are still included. Unlike the root level,
    main
    is not exported. In hindsight, it seems like the issue here is that functions are only included in the output if 1) they're referenced, or 2) they're the root main (rather than being an issue with @JsExport). Is this intended? How can I force the output to include these functions for the purpose of a library?
    a
    • 2
    • 25
  • l

    lilypuchi

    10/17/2022, 3:54 AM
    @Rick Clephas sorry for mentioning you. I’ve an interface in the shared module which I plan to implement the interface in the respective App modules (not in ios, android packages of the kmm module)
    interface FetchTalkUseCase {
        suspend fun execute(talkID: String): Talk
    }
    When I use KMP-NativeCouroutines to generate native async methods, this interface generates the following header file
    __attribute__((swift_name("FetchTalkUseCase")))
    @protocol DomainFetchTalkUseCase
    @required
    
    /**
     @note This method converts instances of CancellationException to errors.
     Other uncaught Kotlin exceptions are fatal.
    */
    - (void)executeTalkID:(NSString *)talkID completionHandler:(void (^)(DomainTalk * _Nullable, NSError * _Nullable))completionHandler __attribute__((swift_name("execute(talkID:completionHandler:)")));
    - (DomainKotlinUnit *(^(^)(DomainKotlinUnit *(^)(DomainTalk *, DomainKotlinUnit *), DomainKotlinUnit *(^)(NSError *, DomainKotlinUnit *)))(void))executeNativeTalkID:(NSString *)talkID __attribute__((swift_name("executeNative(talkID:)")));
    @end;
    Which when I implement in Swift code is as Screenshot. Is it working as intended? Can I restrict it to generate only the
    async
    type ignoring the completionHandler one? 🙇
    r
    • 2
    • 2
  • j

    Jeff Lockhart

    10/17/2022, 6:25 AM
    Given a KMP gradle subproject moduleA with dependencyA (current state of my library), I'm looking for the best way to configure a gradle subproject moduleB that has the following requirements: 1. Add additional code to *moduleA*'s API, both additional classes as well as functions and properties on existing classes (may be achieved via extension functions). 2. Replace dependencyA with dependencyB, which contains *dependencyA*'s API with additions (dependency A and B already exist). 3. Must have access to
    internal
    API of moduleA in moduleB. 4. moduleA and moduleB produce unique published artifacts. I considered adding moduleA as a dependency to moduleB with
    exclude
    for dependencyA, but #3 isn't possible this way. Next I considered adding *moduleA*'s source directories to *moduleB*'s such that the same source files would be compiled along with *moduleB*'s API additions. But I ran into this IDE restriction, where "duplicate content root" error causes the source directories to be removed from moduleB. As a workaround, I've added symlinks from moduleB to *moduleA*'s source directories. While this seems to work, I'm not convinced this is the best way to achieve the goals listed above. Are there other project configuration options I could consider?
  • l

    Lukáš Kúšik

    10/17/2022, 10:49 AM
    There are lots of resources on how to use Flows from Swift. Is there any info on how to create Flows?
    h
    h
    • 3
    • 7
Powered by Linen
Title
l

Lukáš Kúšik

10/17/2022, 10:49 AM
There are lots of resources on how to use Flows from Swift. Is there any info on how to create Flows?
h

hfhbd

10/17/2022, 12:34 PM
You want to implement the Kotlin flow interface in Swift? With all the callbacks and continuation objects and thread issues using the exported objective C API?
l

Lukáš Kúšik

10/17/2022, 12:36 PM
I have a domain interface that I would like to implement in Swift, which contains functions returning Flows.
h

hfhbd

10/17/2022, 12:37 PM
But you could still use some Kotlin functions to create the flow and call it from Swift.
l

Lukáš Kúšik

10/17/2022, 12:39 PM
I can't seem to find emptyFlow(), flowOf(), mutableStateOf(), functions in the exported shared module in Swift. I have created my own proxies for now, but I wonder if there's a different approach. Maybe a way to convert Combine to Flow?
h

hfhbd

10/17/2022, 1:26 PM
You have to export them:
export("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
in your framework in your gradle config. For example:
val xcf = XCFramework()
    iosArm64 {
        binaries {
            framework {
                baseName = "shared"
                export("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
                xcf.add(this)
            }
        }
    }
But I would add some Kotlin helper methods that take some (suspend) lambda: () -> T and use it in a flow builder.
h

humblehacker

10/27/2022, 2:30 AM
@Lukáš Kúšik Have you had any luck getting this to work? I'd also like to implement a function returning a Flow in Swift.
l

Lukáš Kúšik

10/27/2022, 6:51 AM
@humblehacker I just create a MutableStateFlow that I update using setValue from a Combine sink, after exporting the coroutines library to the shared Cocoapod. Not exactly the correct solution but it's a Flow 🤷 😄
View count: 13