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

    Adam Brown

    10/18/2022, 2:49 AM
    Updated IntelliJ and now my multiplatform project is upset. In my JVM "desktop" source set, it doesn't know about any of the JVM classes anymore. Latest IntelliJ and Kotlin 1.7.10, anyone seen this in recent updates?
    • 1
    • 1
  • m

    MarkRS

    10/18/2022, 10:57 AM
    Does the compiler hate expected data class constructors? It seems that any expected primary constructor I write (with corresponding actual versions) complains "Expected class constructor cannot have a property parameter", but if I take it away it complains that data classes have to have a primary constructor. Has AS just got itself in a knot or have I misunderstood something (again 😟)
    a
    • 2
    • 2
  • v

    Vasileios Chroniadis

    10/18/2022, 11:41 AM
    Hello, what is the JDK requirement for KMM? From the docs
    Make sure that you have JDK installed. You can get it from its <https://www.oracle.com/java/technologies/javase-downloads.html|official website>.
    Can I use e.g. openjdk11 or do I have to use the oracle one?
    v
    m
    +3
    • 6
    • 7
  • u

    Umesh Gupta

    10/18/2022, 12:43 PM
    Hello, How can we consume .c or .h or .a files in Common code in kotlin multiplatform and do some File IO and publish it to IOS and Android ?
    j
    • 2
    • 3
  • s

    Stanislav Radchenko

    10/18/2022, 5:23 PM
    Hello, everyone! What is the best architectural approach for KMM? I am interested in the common ViewModel for Android and iOS. I see three main approaches right now: Redux-kotlin, Moko-mvvm and Decompose. Which of these is the best tool to choose for a project from scratch or is there something else?
    k
    s
    +2
    • 5
    • 4
  • k

    Kieren Searle

    10/18/2022, 6:22 PM
    Is it possible to use an xcframework as my staticLibraries input when using cinterop? I'm getting undefined symbols errors when I try
    l
    • 2
    • 3
  • f

    Francois Desrosiers

    10/19/2022, 1:32 AM
    Hi everyone, I'm starting with KMM to build apps for our company. I'm currently using Azure DevOps for CI/CD with the azure native task Gradle@2 to build the android app. When I look at the documentation, it's written that it is like to build android app since it is Kotlin. The problem when I'm executing the command ./gradle assembleRelease nothing happen. I google it and every example they are using Android Studio and it works like a charm but in the context of CI/CD I can't use the tool 🙂. Can someone help me to understand how in command line ( with gradlew) I can generate a APK please. It's probably a very simple question so thank you in advance !
    m
    • 2
    • 5
  • a

    Aleksey Tomin

    10/19/2022, 9:17 AM
    I’ve found some annoyed thing. We have common kotlin code like
    Regex(regexString).matches(valueString)
    And someone has sent string with escaped
    :
    On JVM it works but on JS it leads the error
    Invalid escape
    : https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error I think that common code (for an any parameter) must works or doesn’t work in both platforms. It mustn’t be work on JVM and doesn’t work on JS. What should I do?
  • c

    Claude Brisson

    10/19/2022, 3:03 PM
    Hello everyone. I have the following common code :
    interface SomeInterface {
      @get:Throws(SomeException::class)
      val something: Something
    }
    On jvm it compiles well, but the native compiler gives me the error:
    This annotation is not applicable to target 'member property without backing field or delegate' and use site target '@get'
    How to overcome this limitation? Is there a corresponding YouTrack issue? Thanks.
    a
    • 2
    • 2
  • t

    Trey

    10/19/2022, 8:11 PM
    I'm developing a KMM library and I'm looking at ways to consume it on iOS. Does anybody know if there is a way to do something similar to using includeBuild() in gradle? On Android, we have a dependency on the library that is pulled from a repo. The developer can optionally pull the source for the library and modify the settings.gradle file to swap out that dependency with the source pointed to with includeBuild. This is a popular approach because it allows a developer to quickly iterate when making changes to both the library and app. I'd love to have the iOS app configured in a similar way. Thoughts?
  • e

    eygraber

    10/19/2022, 10:11 PM
    Has anyone tried KMMBridge and run into this issue https://github.com/touchlab/KMMBridge/issues/125
    k
    • 2
    • 1
  • a

    Ademir Queiroga

    10/20/2022, 3:03 AM
    Hey folks, does anyone know/have any source where I can learn more about publishing a KMP library? My end goal is to consume this library on pure JS, I made the code/tests work both for JVM and JS, but the official docs don’t give more info on how to publish (other than to mavenLocal) or to consume the lib.
    a
    b
    • 3
    • 3
  • l

    lilypuchi

    10/20/2022, 2:53 PM
    I have separated the resources into a module which runs entirely on moko-resources. How do I include the generated resources xml files when using
    publishToMaven
    ? Create a separate task to copy the generated xml into android folder? Any help will be appreciated 🙇
    b
    a
    • 3
    • 3
  • i

    Ilya Kalibrov [JB]

    10/21/2022, 1:31 PM
    ❗Hi, everyone ! I am currently running a series of interviews with Kotlin Multiplatform Mobile users, that are using IntelliJ IDEA as a primary IDE for development. If you are willing to spend 30-40 mins on the interview and help us, please, write me in DM :kotlinnew: No pre-requisitions needed ! Thank’s everyone in advance !
    m
    • 2
    • 1
  • e

    elect

    10/21/2022, 4:16 PM
    in
    kotlin.math.MathH
    I can see
    Double.ulp
    but no
    Float
    counterpart..
  • s

    shahroz

    10/21/2022, 10:35 PM
    Hey folks, is there a way to shrink the binary size of iOS framework? started off with just Kotlin my framework size jumped to 1.4 Mb, upon adding Ktor & SQL delight, the framework size has jumped to 16MB. This is huge. I intended on creating KMM library and using it as my native SDKs shared code, but this is too much of size to be okay with. Is there any way to reduce? and library makers actually okay with it?
    v
    • 2
    • 1
  • e

    elect

    10/22/2022, 7:58 AM
    I'd like classes defined in
    commonMain
    to extend specific interface for jvm only. But I'm afraid that's not possible, right? What are the main strategies for this case, other than leaving the interface empty/dummy on the other platform?
    a
    • 2
    • 2
  • v

    Vitaliy Zarubin

    10/22/2022, 10:01 AM
    Hello! I have written 2 compact apps using the latest iOS & Android stack. But it’s all serious, these are full-fledged applications. A pure shared module KMM is integrated in these apps. If anyone is interested, this is a good opportunity to practice integrating common business logic into applications. P.S. to run you will need: * GitHub Application (The applications use the GitHub REST API) * Firebase account (The applications use Firebase dynamic links) * iOS developer account (Associated Domains cannot be enabled without it) P.P.S. If there are some questions I will be happy to answer. Good luck! https://github.com/keygenqt/kmm-GitHubViewer
  • a

    Antonis Radz

    10/22/2022, 11:08 AM
    hey any ideas how to achieve kotlin data class with default arguments like
    data class TestViewState(
        val list: List<Test> = emptyList(),
        val stateText: String = ""
    )
    so on XCode it would have default empty constructor? like
    @State private var viewState: TestViewState = TestViewState()
    Currently it is not working because of XCode error :
    'init()' is unavailable
    It does work as long as it is initialised with values Sorry I am Android dev, not iOS 🙂 (edited) Also made it happen with adding getter to companion object, but this is a hack not a solution
    v
    v
    +4
    • 7
    • 9
  • j

    Jimmy

    10/23/2022, 1:07 AM
    so im trying to add
    realm-kotlin
    to a tiny test project, and I keep getting this error when I try to reference Realm in my android project.:
    Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
        class com.radreichley.kmmrepro.Story, unresolved supertypes: io.realm.kotlin.types.RealmObject
    I get it in my main project, and this barebones repro project. I’ve copied the build.gradle from their example project (
    <https://github.com/realm/realm-kotlin-samples/tree/main/MultiplatformDemo/>
    ), and verified that their project builds fine locally….
  • j

    Jimmy

    10/23/2022, 1:07 AM
    any ideas?
  • j

    Jimmy

    10/23/2022, 1:25 AM
    sigh…… so it was a combination of errors. it turns out they dont reference realm directly from android in their example, so their android build.gradle didnt have any settings. I do so I need to add an additional setting in my android build.gradle.. but when I originally had done that it gave an ‘unresolved artifact’ error because their docs are actually wrong. I had assumed I just didnt need it anymore and removed it…. for those following at home, you need to add
    compileOnly("io.realm.kotlin:library-base:$version")
    rather than
    compileOnly("io.realm.kotlin:library:$version")
  • j

    Jan

    10/23/2022, 9:08 PM
    Hey I added this to the targets: ios() But in iosMain I don't see to have access to the package platform.* Adding all ios targets manually and trying to access that package doesn't help either. Do I have to do anything to access them?
    j
    v
    • 3
    • 5
  • j

    Jozef Matus

    10/24/2022, 12:30 PM
    guys with swift background don’t you miss the ability to define static property inside protocol/interface? I use this technique quite often in Swift. Is there a way how to do this in kotlin?
    v
    c
    +2
    • 5
    • 9
  • u

    Umberto Pompei

    10/24/2022, 2:12 PM
    CommonMain classes are not accessible from androidTest sourceSet while they are from iosTest. I am on kotlin 1.7.20 wit Android Studio Chipmunk. I see few references online of people reporting this and seems to be a bug of IDE/platform , how do you workaround this? See example -> IDatabaseRetriever is declared in commonMain
    l
    z
    c
    • 4
    • 7
  • o

    oday

    10/24/2022, 2:25 PM
    can someone help me understand this section under the code? are they explaining the reasoning behind using the generic Exception class?
    j
    • 2
    • 6
  • e

    eygraber

    10/24/2022, 5:00 PM
    Is the Kotlin version used for gradle dependency resolution with Kotlin native? I have a report about not being able to resolve an artifact using Kotlin 1.7 because the project is using 1.6 https://github.com/eygraber/uri-kmp/issues/56
  • c

    czuckie

    10/24/2022, 5:49 PM
    I've had a look at the multiplatform overview, but I'm confused where android sits compared to desktop - jvmMain sounds like it could target both, but they're very different beasts (at least in the sense android consumes AARs and produces resources etc)
    j
    • 2
    • 3
  • c

    czuckie

    10/24/2022, 11:54 PM
    I've got more of a concrete example to play with now. I've implemented a multiplatform project targeting desktop and android. I've got a library module that has common, desktop and android code, and an android app module and a desktop app module. Both platforms use the exact same implementation of services using a java library that works on both android and desktop. I'd like to not have to duplicate the code, but I don't know how I can achieve re-use in a multiplatform project world.
    e
    j
    a
    • 4
    • 16
  • x

    xiaobailong24

    10/25/2022, 5:30 AM
    Hello, folks. How to call an objc function with
    @protocol
    param in kotlin side? Thanks. https://youtrack.jetbrains.com/issue/KT-54661/KMMObjective-C-function-interop-with-protocol-param
    a
    • 2
    • 2
Powered by Linen
Title
x

xiaobailong24

10/25/2022, 5:30 AM
Hello, folks. How to call an objc function with
@protocol
param in kotlin side? Thanks. https://youtrack.jetbrains.com/issue/KT-54661/KMMObjective-C-function-interop-with-protocol-param
a

Andrei Salavei

10/25/2022, 10:09 AM
Hey, are you talking about this one?
OBJC_EXPORT Protocol * _Nullable
objc_getProtocol(const char * _Nonnull name)
    OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0);
x

xiaobailong24

10/25/2022, 12:35 PM
Thanks for your reply. It should not be the same one.
View count: 9