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

    Alexandru Caraus

    08/05/2021, 6:20 PM
    Is it possible to split the multiplatform code, to have multiple modules?
    c
    m
    • 3
    • 7
  • l

    Laurence Muller

    08/06/2021, 12:58 AM
    👋 Hello, I'm currently running into an issue where I have a simple test KMM project (depending on coroutines, ktor, serialization and decompose/mvikotlin) where things are fine on the Android side but on the iOS side things seem a bit odd. The build job (from the KMM plugin) for iOS seems to be successful for the shared module
    > Task :shared:compileKotlinIos
    > Task :shared:linkDebugFrameworkIos
    > Task :shared:syncFramework
    
    BUILD SUCCESSFUL in 35s
    3 actionable tasks: 3 executed
    But then as soon as it starts building the swift app (unmodified demo app):
    CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler (in target 'iosApp' from project 'iosApp')
    It keeps throwing a bunch of
    <module-includes>:1:9: note: in file included from <module-includes>:1:
    #import "Headers/shared.h"
            ^
    /Users/xxx/Prototype/TestBaseApp/shared/build/cocoapods/framework/shared.framework/Headers/shared.h:1337:37: error: expected identifier
    - (instancetype)initWithDEBUG:(BOOL)DEBUG APPLICATION_ID:(NSString *)APPLICATION_ID BUILD_TYPE:(NSString *)BUILD_TYPE FLAVOR:(NSString *)FLAVOR VERSION_CODE:(int32_t)VERSION_CODE VERSION_NAME:(NSString *)VERSION_NAME GIT_HASH:(NSString *)GIT_HASH MY_API_BUILD_ID:(NSString *)MY_API_BUILD_ID MY_API_CLIENT_ID:(NSString *)MY_API_CLIENT_ID MY_API_CLIENT_NAME:(NSString *)MY_API_CLIENT_NAME PLATFORM:(NSString *)PLATFORM OS:(NSString *)OS OS_VERSION:(NSString *)OS_VERSION PHONE_BRAND:(NSString *)PHONE_BRAND PHONE_TYPE:(NSString *)PHONE_TYPE __attribute__((swift_name("init(DEBUG:APPLICATION_ID:BUILD_TYPE:FLAVOR:VERSION_CODE:VERSION_NAME:GIT_HASH:MY_API_BUILD_ID:MY_API_CLIENT_ID:MY_API_CLIENT_NAME:PLATFORM:OS:OS_VERSION:PHONE_BRAND:PHONE_TYPE:)"))) __attribute__((objc_designated_initializer));
                                        ^
    <command line>:16:15: note: expanded from here
    #define DEBUG 1
                  ^
    <module-includes>:1:9: note: in file included from <module-includes>:1:
    #import "Headers/shared.h"
            ^
    /Users/xxx/Prototype/TestBaseApp/shared/build/cocoapods/framework/shared.framework/Headers/shared.h:1359:27: error: expected member name or ';' after declaration specifiers
    @property (readonly) BOOL DEBUG __attribute__((swift_name("DEBUG")));
                              ^
    <command line>:16:15: note: expanded from here
    #define DEBUG 1
                  ^
    <module-includes>:1:9: note: in file included from <module-includes>:1:
    #import "Headers/shared.h"
    and keeps repeating a few times complaining about the things in
    Headers/shared.h
    and finally ending with:
    /Users/xxx/Prototype/TestBaseApp/iosApp/iosApp/ContentView.swift:2:8: error: could not build Objective-C module 'shared'
    import shared
           ^
    
    ** BUILD FAILED **
    
    
    The following build commands failed:
    	CompileSwift normal x86_64 /Users/xxx/Prototype/TestBaseApp/iosApp/iosApp/iOSApp.swift
    	CompileSwift normal x86_64 /Users/xxx/Prototype/TestBaseApp/iosApp/iosApp/ContentView.swift
    	CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
    Any thoughts on if it is some kotlin syntax the compiler doesnt like or how I can make the compiler be a bit more verbose to point out what it is struggling with? (I'm using kotlinVersion 1.5.21 and coroutines 1.5.0-native-mt)
    :rubber_duck: 1
    o
    • 2
    • 3
  • l

    langara

    08/06/2021, 8:56 AM
    Hi, what is the prettiest way to check if I'm on main thread (and throw otherwise)? I guess inside coroutine it should be sth like:
    check(coroutineContext[ContinuationInterceptor] === Dispatchers.Main) { "TreeUiModel.logic must run o main!" }
    But how to do it outside? (from regular function without coroutine scope/context)
    ➕ 1
    m
    e
    • 3
    • 3
  • a

    Anutosh Datta

    08/06/2021, 12:12 PM
    Hi, I am having issues with cocoapods integration. Below is the cocoapods block in build.gradle.kts file
    cocoapods {
        summary = ""
        homepage = ""
        frameworkName = ""
    
        pod("Mixpanel")
        pod("FirebaseCore")
        pod("FirebaseMessaging")
        pod("SSZipArchive")
    }
    I get the following error when running gradle sync.
    Exception in thread "main" java.lang.Error: /var/folders/ny/hf6sbtc5337bl6g_tcy7kcg80000gp/T/4577319926544642637.m:1:9: fatal error: module 'FirebaseCore' not found
       
    at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
        at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:68)     at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14)     at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:515)     at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:266)     at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76)     at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)     at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38)     at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)
    a
    v
    • 3
    • 7
  • l

    Laurence Muller

    08/08/2021, 12:12 AM
    Hi, for the iOS framework distribution, some projects use the "regular framework" and just add in their exports like this: ( https://kotlinlang.org/docs/mpp-build-native-binaries.html#export-dependencies-to-binaries )
    iosTarget("ios") {
        binaries {
            framework {
                baseName = "shared"
                export("com.arkivanov.decompose:decompose:0.3.1")
                export("com.arkivanov.essenty:lifecycle:0.1.2")
            }
        }
    }
    But what if I created my projects with the KMM plugin which by default sets it to the "CocoaPods dependency manager" how would I add those exports?
    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        ios.deploymentTarget = "14.1"
        frameworkName = "shared"
        podfile = project.file("../iosApp/Podfile")
    
        // How to include the same exports?
    }
    v
    • 2
    • 2
  • h

    Hossein Amini

    08/08/2021, 5:13 AM
    Hi, how can I use GraphQL in KMM projects. Because Apollo requires iOS 13+ we’re looking for an alternative.
    m
    • 2
    • 10
  • r

    rkeazor

    08/08/2021, 1:34 PM
    Anyone using the latest version Kmm with Ktor and serialization ? what dependencies are you using in your build.gradle
    j
    • 2
    • 2
  • h

    Hossein Amini

    08/09/2021, 6:11 AM
    Is it possible to use an iOS library that is written completely with swift in shared module?
    m
    • 2
    • 1
  • a

    aiidziis

    08/09/2021, 10:40 AM
    Hey! I am using this guide to include SQLCipher in my project. At first it worked fine until I added my first migration. Now when I run my code it throws out expection on iOS:
    [logging] file is not a database in "PRAGMA journal_mode"
    error while compiling: PRAGMA journal_mode | error code SQLITE_NOTADB
    co.touchlab.sqliter.interop.SQLiteExceptionErrorCode: error while compiling: PRAGMA journal_mode
    Has anyone encountered the same issue?
    😱 1
    m
    s
    • 3
    • 11
  • r

    robjperez

    08/09/2021, 10:42 AM
    Hi there!, I’m using a code that uses Metal or OpenGL depending on if this runs on iphone or iphonesimulator. What’s the KMM approach to do this kind of
    ifdef
    ?
    k
    • 2
    • 13
  • g

    Gaurav Singh

    08/09/2021, 6:46 PM
    Hi Team…I am new to multiplatform, I have a bootstrap CSS template. Can anybody tell me, If I can use that in Kotlim MM
    b
    • 2
    • 3
  • r

    robstoll

    08/09/2021, 10:24 PM
    why does allTest not fail if it failed previously? I worked around (I still let it fail if it failed without the need to execute the tests again) but I realised that gradle's test task does not have the same behaviour. And what surprised me even more is that :jvmTest also executes the test again if it failed previously.
    r
    • 2
    • 2
  • m

    Matthias Geisler

    08/10/2021, 5:05 PM
    Already asked in the native channel...but no answer this so: Does anybody knows how generate more or less meaningful code coverage reports for iOS in KMM projects? I played with a little bit based on the JetBrains sample project, but I get always 100% in my own example which has deliberate blindspots or it simply breaks under if I only something partially for iOS.
    l
    • 2
    • 1
  • t

    tylerwilson

    08/10/2021, 6:19 PM
    I am trying to get atomicfu and/or stately working in my common module. i add the implementation lines, but they show as not available in the code. anybody have an example of using these from kmm common module?
    k
    • 2
    • 16
  • n

    Nikola Milovic

    08/11/2021, 6:36 AM
    Adding a dependency to my commonMain, breaks the source root (no code checking, no autocompletion), and just this one dependency. Before raising an issue on github, what can be the cause of this? Is something on my end?
    b
    • 2
    • 1
  • h

    Hossein Amini

    08/11/2021, 7:56 AM
    Is there any library to convert models to GraphQL queries? We want to use Ktor not Apollo.
    g
    • 2
    • 1
  • p

    Paul Dhaliwal

    08/11/2021, 4:39 PM
    Hello, if I’ve been building a Kotlin Multiplatform Mobile library up until now, and I decide to start adding JS support, is it as simple as adding js() target in the Kotlin block of the build file? Or will there be complications since I started with the KMM template instead of the KMP template?
    a
    d
    +3
    • 6
    • 7
  • k

    kevindmoore

    08/12/2021, 5:00 AM
    Does anyone know what the following error means? (everything else seems to compile):
    Task :shared:compileKotlinMetadata FAILED
    t
    m
    • 3
    • 4
  • r

    robjperez

    08/12/2021, 11:48 AM
    And I have another question 😅 , I’m trying to add some platform specific test, and I’m having some issues. • There is a strange
    androidAndroidTestRelease
    autogenerated source set • If I put the tests on
    androidTest/kotlin
    I cannot run the tests because AS says “No task available” • If I put the tests on
    androidAndroidTest/kotlin
    then AS runs the tests, but it looks like the tests are not included in the apk so no tests are run
    k
    s
    +2
    • 5
    • 20
  • k

    Konyaco

    08/12/2021, 2:50 PM
    Hi! I'm trying to build a multiplatform app, but I can't use some of libraries (such as javax.sound) in jvm sourceset. 🤔 Gradle build script is in thread.
    • 1
    • 1
  • v

    v79

    08/13/2021, 7:05 AM
    Is "multiplatform" just a synonym for "iOS" at Jetbrains? I see very little evidence of them treating MS Windows as a first class platform.
    y
    e
    c
    • 4
    • 4
  • m

    MarkRS

    08/13/2021, 10:03 AM
    I think I need a "multiplatform-getting-started" channel, because this sounds like a very simple question. It probably shows I don't understand. Where, and how, do I include a properly platform specific implementation of a function? I've got a class "GuTime" marked as expected in /shared/src/commonMain. The Android version seems happy in /shared/src/commonAndroid, or probably even /app/src/<etc>, but what about the iOS version? iOS doesn't have "systemtime" so I need an iOS route. I can't put that in /shared/src/commonIOS (can I?), and trying to put an "actual" class in /iOS/ complains about "actual". Yes, I know there's a Kotlin time package on the way, but how "alpha" is it? And that would only help for this specific issue.
    m
    • 2
    • 7
  • h

    Hossein Amini

    08/13/2021, 3:53 PM
    When I rebuild the KMM project it says`Could not resolve all files for configuration '😒hared:lintClassPath'` The greadle version is 4.2.2 and the project runs with no problem.
    h
    • 2
    • 1
  • h

    Hossein Amini

    08/14/2021, 1:45 PM
    Is there any library to mock objects in commonTest?
    b
    • 2
    • 1
  • m

    Michal Lepíček

    08/16/2021, 8:10 AM
    Is there a possibility to target android with kotlin, but having android sdk code accessible only from androidMain? Not from commonMain and others?
    c
    j
    m
    • 4
    • 11
  • m

    MarkRS

    08/16/2021, 10:45 AM
    I'm not even sure how to frame a sensible question about Parcelize, KMM, and iOS. In essence I have a fundamental class marked as parcelable because I can have some of my basic data correctly packaged by my server, by the magic of KTor (and, to be fair, others) decoded completely and can then display it using that same structure in my Android app. KMM has an implementation of Parcelize, but what do I do for iOS??? I know I don't need data to be parcelable for iOS, but, as a basic data structure, I have it declared as expecting in commonMain and an actual declaration in adroidMain, and now iosMain is complaining it has no actual declaration. I'm beginning to suspect I shouldn't have that data put straight into a parcelable/parcelizable object, which means I've got extra overhead somewhere creating a new object from it, at least in my Android executable, but if that's the case, why does KMM go out of its way to provide a parcelizable construct?
    r
    d
    +3
    • 6
    • 17
  • f

    Francis Mariano

    08/17/2021, 1:32 PM
    Hello guys, are there any library to perform file tasks (create/read/write/delete) in Android/iOS???
    j
    m
    +2
    • 5
    • 6
  • a

    Akram Bensalem

    08/18/2021, 1:40 PM
    I creat a new project with Compose multiplatform but I got this error
    a
    • 2
    • 6
  • w

    wbertan

    08/18/2021, 3:21 PM
    Anyone knows if it is possible to import existing KMM project having Android + iOS (with
    xcworkspace
    and
    xcodeproj
    ) to AppCode with the KMM Plugin? In the blog post announcing the plugin they mention this:
    We’re working on a solution that will allow you to hook up an existing 
    .xcodeproj
     or 
    .xcworkspace
     to the Gradle DSL to make it possible to easily connect existing Xcode projects with the common and Android parts.
    But could not find anything else related to that.
    y
    a
    • 3
    • 2
  • j

    Jonas Frid

    08/19/2021, 8:58 AM
    When will we have access to kotlin.reflect.full from KMM?
    l
    • 2
    • 10
Powered by Linen
Title
j

Jonas Frid

08/19/2021, 8:58 AM
When will we have access to kotlin.reflect.full from KMM?
l

louiscad

08/19/2021, 9:09 AM
Never, because it's too heavy for Android anyway.
However, there's some compile time reflection being worked on, which maybe, maybe a few years from now might be usable.
j

Jonas Frid

08/23/2021, 12:50 PM
Well. It kind of makes a lot of stuff harder, like mocking for test and creating automatic object mappers etc. Most frameworks/platforms/languages has reflection for doing things like that even though you need to be careful about performance.
l

louiscad

08/23/2021, 12:52 PM
You can replace mocks by fakes, it works fine everywhere and requires no "magic".
For other cases, we tend to use Kotlin compiler or Gradle plugins, or #ksp to generate code at compile time instead of having the cost of reflection affecting operation in production.
For example, kotlinx #serialization relies on a compiler plugin.
j

Jonas Frid

08/23/2021, 12:54 PM
Of course you can use fakes, but mocking is convenient
l

louiscad

08/23/2021, 12:54 PM
Fakes are not that inconvenient on the long run
Plus you don't need mental shift, it works just like without fakes
j

Jonas Frid

08/23/2021, 1:16 PM
Well, I disagree, but it is a matter of opinion I guess. I like the convenience of defining my mock object dynamically instead of having stubbed mock classes, but that looks like the option available at the moment.
View count: 5