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

    Slackbot

    09/23/2022, 9:38 AM
    This message was deleted.
    e
    • 2
    • 2
  • c

    coolcat

    09/23/2022, 3:56 PM
    Does anybody have any tips for how I can get Xcode to recognise Cocoapods? I have a KMM project using Cocoapods and the build step is giving:
    Execution failed for task ':shared:podGenIOS'.
    > 'pod install' command failed with an exception:
       Cannot run program "pod" (in directory "/Users/.../shared/build/cocoapods/synthetic/IOS"): error=2, No such file or directory
              
              Full command: pod install
              
              Possible reason: CocoaPods is not installed
              Please check that CocoaPods v1.10 or above is installed.
              
              To check CocoaPods version type 'pod --version' in the terminal
              
              To install CocoaPods execute 'sudo gem install cocoapods'
    Needless to say Cocoapods working fine from the command line.
  • e

    eygraber

    09/25/2022, 8:39 PM
    Is there any way to override the
    removeEldestEntry
    of a
    LinkedHashMap
    ?
    d
    e
    • 3
    • 4
  • m

    Martin Štrambach

    09/26/2022, 11:10 AM
    Hi everyone, I have a question regarding Kotlin vs Objc/Swift static properties. Kotlin doesn’t have any explicit support of static functions. Instead, we use companion objects. Following example is often used in factory classes.
    class MyClass {
      ...
      companion object {
        fun companionFun()
      }
    }
    When we generate ObjC code out of this example it creates one interface for
    MyClass
    and another one for
    MyClass.Companion
    . Then, in Swift we use it as
    MyClass.companion.companionFun()
    . The issue is
    companion
    nor
    companionFun
    aren’t static because
    companion
    is a singleton object. Is there a way how to generate Swift static functions for Kotlin functions without the need of second interface? I found one feature ticket which would potentially solve this issue but it is without any activity for a long time. https://youtrack.jetbrains.com/issue/KT-44862
  • r

    Robert Wijas

    09/26/2022, 12:09 PM
    Does running single KMM test in Android Studio Dolphin work for you? It used to work, Studio was creating ad hoc gradle run configuration. Now it creates JUnit configuration, but I cannot run them, because Run button is disabled and I cannot find any error that could give me a clue why it doesn’t work. This is driving me crazy 😤. TIA 🙏
    m
    m
    a
    • 4
    • 8
  • l

    Landry Norris

    09/26/2022, 1:14 PM
    I just migrated a KMM project using embedded framework for the shared iOS framework to use cocoapods to match new requirements in the project. I have the project building the shared module using cocoapods just fine when I run through XCode, but when I run on iOS through Android Studio using the KMM plugin, I get an error that /path/to/build/null.app is not found. I would assume it’s looking for $EXECUTABLE_NAME, but that seems to be set. What should I be looking at to fix this?
    • 1
    • 1
  • s

    svenjacobs

    09/27/2022, 5:48 AM
    Hey, not sure if my request is suited for #compose or here so I just post it here: I’m currently writing a multiplatform application with a shared Compose UI for the Android and JVM platforms. I struggle with the
    @Preview
    annotation. Although I added the
    compose.preview
    dependency
    val commonMain by getting {
    	dependencies {
    		implementation(compose.runtime)
    		implementation(compose.foundation)
    		implementation(compose.ui)
    		implementation(compose.uiTooling)
    		implementation(compose.preview)    // <--- see here
    	}
    }
    the
    androidx.compose.ui.tooling.preview.Preview
    annotation is not found in the classpath of the code placed in
    commonMain
    . What am I doing wrong? JetBrains Compose
    1.2.0-beta01
    , Android Studio Electric Eel Beta 1
  • k

    Kevin Zhang

    09/27/2022, 7:53 AM
    i have figured out this issues using
    from\into in the bootJar task
    copy js files into the target directory:
    tasks.getByName<BootJar>("bootJar") {
        val webpackTask = tasks.getByName<KotlinWebpack>("reactBrowserDevelopmentWebpack")
        dependsOn(webpackTask) // make sure JS gets compiled first
    
        from(File(webpackTask.destinationDirectory, webpackTask.outputFileName)){
            into("BOOT-INF/classes/static/js/src")
        }
        archiveBaseName.set("${project.name}-with-dependencies")
        mainClass.set("com.kevin.FullStackApplicationKt")
        archiveClassifier.set("boot")
    }
  • f

    Friedger

    09/29/2022, 4:02 PM
    Is there any KMM support for NFCs? Some libraries or projects?
  • m

    Meherdatta Chepuri

    09/29/2022, 7:09 PM
    👋 Hello, team! What would be the recommended approach to set up the KMM project and repo? Is it better to have iOS and Android apps in the same repo along with the shared module or is it better to separate them out? wanted to check the experience so far from the community with different approaches. Curious to hear some great use-cases!
    s
    x
    s
    • 4
    • 5
  • p

    Piotr Prus

    09/29/2022, 10:41 PM
    I have an issue with moko-resources, but didnt get any update from maintainers for some time. Maybe some of you know how to fix it or where to look for working example so I can check the setup: https://github.com/icerockdev/moko-resources/issues/386
  • m

    Mike Digman

    09/30/2022, 1:30 AM
    Heya folks, I'm working in Compose Multiplatform (with Compose 1.1.1) and I'm seeking a cross-platform (Android + Desktop) way to capture a given Composable already rendered to the screen in an
    ImageBitmap
    . I'm aware of
    ImageComposeScene
    in Compose Desktop and the various Android
    View
    mechanisms that uses the the backing canvas. Is there anything cross-platform?
  • t

    Tijl

    09/30/2022, 9:31 AM
    not sure if that can be fixed easily, but an alternative is to expect extension properties for
    red
    ,
    blue
    etc
    d
    • 2
    • 1
  • k

    Kartik Prakash

    09/30/2022, 4:30 PM
    Anyone seen this error before:
    Reason: AMDeviceSecureInstallApplicationBundle failed with err = -402620375(The code signature version is no longer supported.)
  • d

    diesieben07

    09/30/2022, 6:56 PM
    I'm trying to enable context receivers in a multiplatform project. It works for the JVM module if I do
    kotlinOptions.freeCompilerArgs += listOf("-Xcontext-receivers")
    in the JVM compilation. But I don't know how to do it for the common module, since it does not seem to have a compilation. The IDE keeps reporting "The feature "context receivers" is experimental and should be enabled explicitly" in common code.
    e
    • 2
    • 2
  • k

    Kirill Zhukov

    10/01/2022, 12:15 AM
    If I want to add a Swift package or XCFramework as a dependency into a native source set, what are my options? I imagine I need to generate
    .def
    file and link binaries or something, is there Gradle plugin or examples on how to do that? (relatively new to KMM as well as Native ecosystem)
    • 1
    • 6
  • g

    Gillian Buijs

    10/01/2022, 11:20 AM
    My C knowledge is severely limited so this question might be a bit dumb but.... Is it possible to compile a KMM module to a single C artifact? Right now I build an XCFramework and .aar file but I was wondering if it's possible to output a single C library which then could be invoked through ffi (dart). Right now my project uses methodchannels but that has (de)serialisation overhead so using ffi would be more performant. So far all I can find is using C in KMM but I actually would want it the other way around including platform specific code.
    j
    • 2
    • 1
  • e

    Eugene Maksymenko

    10/02/2022, 8:42 PM
    👋 Hello, team! Let me introduce WorldWind Kotlin - the first multi-platform planetary 3D globe library for JS, Android and JVM
    d
    • 2
    • 1
  • a

    Arun Joseph

    10/03/2022, 7:32 PM
    Hi All, When I try this tutorial - https://kotlinlang.org/docs/multiplatform-mobile-upgrade-app.html i get this crash on iOS simulator. See thread
    • 1
    • 3
  • h

    hfhbd

    10/04/2022, 3:45 PM
    Use Swift 5.5 and @MainActor to switch back to the main thread
    m
    • 2
    • 3
  • s

    Smorg

    10/04/2022, 7:29 PM
    Wondering if anyone uses AppCode for Kotlin Multiplatform Mobile, what’s the experience like? Getting some IDE errors in the Android module, and I am just evaluating if it is going to be worth it to try resolving the errors.
    d
    a
    • 3
    • 4
  • k

    Kartik Prakash

    10/05/2022, 1:42 AM
    Hi all I’m having some issues running iOS app on a real device using XCode 14.0.1 and keep getting this error
    ld: '/shared/build/cocoapods/synthetic/IOS/build/Release-iphoneos/FirebaseCrashlytics/FirebaseCrashlytics.framework/FirebaseCrashlytics' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/shared/build/cocoapods/synthetic/IOS/build/Release-iphoneos/FirebaseCrashlytics/FirebaseCrashlytics.framework/FirebaseCrashlytics' for architecture arm64
    Has anyone seen this issue or know a workaround?
    l
    • 2
    • 5
  • z

    zt

    10/05/2022, 3:47 AM
    How do I add Android support to my multiplatform project? I'm developing a library
    s
    • 2
    • 1
  • f

    Foso

    10/05/2022, 11:03 AM
    https://github.com/LouisCAD/CompleteKotlin
    t
    j
    l
    • 4
    • 17
  • g

    Greg

    10/05/2022, 5:54 PM
    Are custom equals/hashCode implemented in shared code in data classes carried over when using them in iOS project?
  • t

    Tolriq

    10/06/2022, 6:38 AM
    This is probably an edge case but maybe there's something easy to fix this. I'm using a KMP library as a composite build inside a pure Android application. Android Studio (Flamingo) is having issues resolving dependencies between modules inside that library. Everything works at compile time and opening the library in AS directly works correctly too. I have no idea where to start looking at since there's no errors at compile time and it's IDE issue only.
    t
    a
    +3
    • 6
    • 7
  • s

    Sarav Ramaswamy

    10/06/2022, 9:36 PM
    Hello, I tried to search this channel but I cannot find. I am looking for a working example of multiplatform library with iOS and Android targets? Sorry if this is often repeated question.
    m
    b
    • 3
    • 2
  • d

    darkmoon_uk

    10/07/2022, 8:51 AM
    In which plugin is the
    packForXcode
    /`buildForXcode` task implemented - has it been deprecated?
    j
    r
    l
    • 4
    • 41
  • z

    zt

    10/08/2022, 4:21 AM
    How can I add a target for jvm on windows and one for linux that both use the common code?
    j
    e
    • 3
    • 12
  • a

    Adam Cooper

    10/08/2022, 7:26 PM
    I'm looking for a resource which explains how I can reference JavaScript from a Kotlin/JS target inside of a Kotlin/JVM target. For example, I have a Ktor server in Kotlin/JVM and I want to serve scripts like this:
    routing {
        static("scripts") {
            ... // Serve JavaScript files from this endpoint
        }
    }
    But instead of just writing JavaScript, I'd prefer to write Kotlin which is then compiled to JavaScript, and serve those generated files. I found the full-stack tutorial in the docs, but the server is written in JavaScript and serves a full React application. I am serving a mostly-static webapp with a little bit of JavaScript.
    j
    • 2
    • 5
Powered by Linen
Title
a

Adam Cooper

10/08/2022, 7:26 PM
I'm looking for a resource which explains how I can reference JavaScript from a Kotlin/JS target inside of a Kotlin/JVM target. For example, I have a Ktor server in Kotlin/JVM and I want to serve scripts like this:
routing {
    static("scripts") {
        ... // Serve JavaScript files from this endpoint
    }
}
But instead of just writing JavaScript, I'd prefer to write Kotlin which is then compiled to JavaScript, and serve those generated files. I found the full-stack tutorial in the docs, but the server is written in JavaScript and serves a full React application. I am serving a mostly-static webapp with a little bit of JavaScript.
j

jw

10/08/2022, 9:53 PM
I don't have a tutorial, but I do that with https://github.com/JakeWharton/PosterBox/ if you want to take a look at the build scripts and such
a

Adam Cooper

10/08/2022, 10:05 PM
Thank you! I think this is not quite what I'm looking for. I did figure out how to get the JS served by the backend, but I essentially have this:
head {
            script(type = ScriptType.textJavaScript, src = "/static/scripts/adamcooper-sh.js") {}
}
which does download the script successfully, so that's good. But I am unsure how to load functions from the script.
button(classes = "fa fa-copy wordleCopyButton") {
    onClick = 
"copyToClipboard(document.getElementById('$solutionID'));"
}
The
copyToClipboard
function comes from my compiled JS. It throws a
ReferenceError
because it can't find the reference.
j

jw

10/08/2022, 11:17 PM
And you're writing this using kotlinx.html on the backend? There won't be a way to safely reference the functions. You have to export them from your JS and then reference them as strings but you still need a module to load. Otherwise you'd have to expose them on
globalThis
so they're available as top-level functions like you've written there.
I would recommend giving the button an ID and then having the main function of your JS do an ID-based lookup and attach the click listener itself
a

Adam Cooper

10/08/2022, 11:21 PM
That's a much more reasonable approach. That's me, a backend engineer, trying to write front end :D
View count: 13