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

    curioustechizen

    02/26/2020, 11:15 AM
    I've a fundamental question about
    expect/actual
    . Is Kotlin code in
    commonMain
    supposed to be able to access code in
    iosMain
    or
    androidMain
    even without using the
    expect/actual
    mechanism? So, if I have different implementations of
    fun getPlatformName(): String
    each in
    iosMain
    and
    androidMain
    , but I don't declare
    expect fun getPlatformName(): String
    in
    commonMain
    am I still supposed to be able to call this function from
    commonMain
    ?
    🇳🇴 4
    r
    r
    k
    • 4
    • 14
  • s

    Sean Keane

    02/26/2020, 12:22 PM
    I seem to be having an issue with my multi platform config, Its not autocompleting for ios or js. When I try to implement a
    map
    across all three platforms, the packages aren’t being imported. Has anyone else had this issue and managed to rectify it?
    r
    • 2
    • 7
  • s

    Steven

    02/26/2020, 1:30 PM
    Hi, I was wondering if anyone had to work with kotlin multiplatform and j2objc in one project. The current shared code stack of our projects is mainly j2objc, but we would like to move it slowly towards kmp. Is there a way to have both cores communicate with each other (or at least communicating one-way)?
    s
    k
    • 3
    • 3
  • n

    Nikita Khlebushkin

    02/26/2020, 6:09 PM
    I'm running an iOS project with KMP dependency with cocoapods plugin. I ran
    podspec
    , then specified
    pod 'my-pod', :path => '../my-pod'
    in project's Podfile and ran
    pod install
    . I can import classes in Xcode and autocomplete works just fine, but when I try to build it, I get
    Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_AnalyticsInitParameters", referenced from:
          objc-class-ref in ContentView.o
      "_OBJC_CLASS_$_AnalyticsAnalytics", referenced from:
          objc-class-ref in ContentView.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    What am I doing wrong? Did I skip anything?
    k
    • 2
    • 20
  • n

    Nikita Khlebushkin

    02/26/2020, 10:41 PM
    Yet another question about cocoapods + KMP: how do I build fat framework (more than one target, eg. iosX64 and iosArm64) using cocoapods?
    s
    a
    • 3
    • 8
  • d

    darkmoon_uk

    02/27/2020, 8:58 AM
    Just gave an 1h 20m presentation to our head office advocating a K/MP strategy for the future of our product... 🤞fingers crossed!
    🙌 3
    🤞 4
    s
    t
    • 3
    • 14
  • r

    ritesh

    02/27/2020, 9:57 AM
    Hey folks 👋 Wondering if
    reified inlined function
    is not yet supported in KMP for iOS? Basically I have wrapped
    Json.nonstrict.parseList
    in a different function which looks like
    inline fun <reified T : Any> listParser(): List<T> { ... }
    . It’s crashing on iOS saying
    Uncaught Kotlin exception: kotlin.IllegalStateException: unsupported call of reified inlined function
    though it’s working fine on Android. Just wanted to check if it’s not supported or am I doing something wrong 😅
    j
    • 2
    • 3
  • d

    dambakk

    02/27/2020, 10:06 AM
    This might be a very basic question, and I know there is an
    expect/actual
    answer to this question, but I cant seem to figure it out. We are using
    Klock
    to handle dates in our mpp project. How can we expose this type as a
    NSDate
    for the ios platform?
    🇳🇴 2
    a
    • 2
    • 5
  • j

    Jeff

    02/27/2020, 12:07 PM
    Hello. I have this actual implementation in js and iOS but runBlocking is unresolved. It is only resolved in JVM. Whats the matter?
    import kotlinx.coroutines.runBlocking
    
    internal actual fun <T> runTest(block: suspend () -> T): T {
        return runBlocking { block() }
    }
    s
    d
    • 3
    • 18
  • t

    Tim Hauptmann

    02/27/2020, 12:20 PM
    Hey, I use Sqldelight on iOS and want to put my database file into a specific folder:
    NativeSqliteDriver(MyDatabase.Schema, "file:///private/var/mobile/Containers/Shared/AppGroup/.../test.db")
    But this is forbidden by:
    private fun checkFilename(name: String) {
      if (name.contains("/")) {
        throw IllegalArgumentException(
          "File $name contains a path separator"
        )
      }
    }
    Someone knows the proper way to setup this?
    t
    • 2
    • 2
  • c

    CLOVIS

    02/27/2020, 3:07 PM
    Is there a good quality guide on how to actually setup unit testing in Kotlin/JS for a multiplatform library? I've been following SO answers & stuff but the best I could find is 2 years old and very imprecise.
    r
    j
    • 3
    • 17
  • j

    Jeff

    02/27/2020, 4:51 PM
    I am doing a multiplatform library that supports android. Is the JVM target enough in build.gradle or should I add an Android target?
    k
    c
    a
    • 4
    • 8
  • c

    CLOVIS

    02/27/2020, 5:42 PM
    Hi! I have a problem with the Multiplatform JS setup (with the Gradle plugin). When running:
    ./gradlew jsTest
    I get:
    > Task :kotlinNpmInstall FAILED
    error package.json: Name contains illegal characters
    I tracked it down to this GitHub issue: https://github.com/yarnpkg/yarn/issues/1120 which says it's a problem of whitespace character in the project name. I do have whitespace in the name of my project, since that's allowed with Gradle—but apparently it's not with Yarn. Is there a way to tell the Multiplatform plugin to escape the whitespace with something else (for example underscores) automatically? I found the generated
    package.json
    in
    build/js/package.json
    and the name of the project does contain spaces there as well.
    👍 1
    e
    i
    • 3
    • 4
  • j

    Joan Colmenero

    02/27/2020, 7:55 PM
    Hello guys, I'm playing with Kotlin MP and on my iosMain using Android Studio I'm not able to import libraries like the Log from Swift any idea?
    k
    a
    r
    • 4
    • 34
  • s

    Sebastien Leclerc Lavallee

    02/28/2020, 5:21 AM
    Hi! I added RxCommon to my multiplatform setup, I want to create an observer inside my swift code to be able to be notified when changes. The class
    Observer
    is defined inside RxCommon which is linked in the
    sourceCommon
    source set. If I try to instanciate an Observer, XCode doesn’t find this class. How is it possible to access classes inside external libraries from the Swift code? I can do this inside one of my Android app’s Activity. Thanks!
    k
    • 2
    • 8
  • n

    Nikita Khlebushkin

    02/28/2020, 12:01 PM
    Hello! I have this error after compiling KMP library with cocoapods
    There is a library attached to the project that was compiled with an older Kotlin/Native compiler and can't be read in IDE:
    			"analytics-cinterop-Analytics.klib" at $project/analytics/build/classes/kotlin/iosX64/main/analytics-cinterop-Analytics.klib
    			Please edit Gradle buildfile(s) to use Kotlin Gradle plugin version 1.3.61. Then rebuild the project and re-import it in IDE.
    The only place that I apply multiplatform plugin has
    kotlin("multiplatform") version "1.3.61"
    How can I fix it?
    a
    • 2
    • 23
  • o

    Orhan Tozan

    02/28/2020, 1:59 PM
    Hi guys, I already have several modules that have no reference to android/ios. So really pure Kotlin modules, business logic etc. The idea is the following three following repo's: • core • android implementations • ios implementations So I don't want to use the expect, actual mechanism, but just the interface/implementation mechanism. How do I set something like this up?
    k
    r
    • 3
    • 113
  • s

    Sylvain Patenaude

    02/28/2020, 3:07 PM
    Can I use @Throws in multi-platform (common) code? EDIT: My code is 99% common (with the 1% being some platform-specific tweaks ). But I would still need to add @Throws annotations to several methods so that the iOS consumers of my iOS-generated library can try/catch these methods. Any idea how I could achieve this?
    k
    • 2
    • 1
  • s

    Sebastien Leclerc Lavallee

    02/28/2020, 4:53 PM
    Hey guys! I did setup exporting dependencies to be able to use a library inside my Swift code. It seems to have worked partially. I’m exporting RXCommon and when inside the Swift code, I see only interfaces and some abstract classes but most of the interesting classes aren’t available. Does that ring a bell to someone? Thanks!
    r
    • 2
    • 3
  • o

    Orhan Tozan

    02/29/2020, 12:06 AM
    I'm getting the following error for in a common mpp module of mine:
    Cannot access built-in declaration 'kotlin.Nothing'. Ensure that you have a dependency on the Kotlin standard library
    s
    • 2
    • 3
  • o

    Orhan Tozan

    02/29/2020, 12:13 AM
    I invalidated cache and restarted it, why woould this error occur?
    l
    • 2
    • 1
  • n

    nrobi

    03/02/2020, 6:40 AM
    Does K/N generate `_Nullable`/`_NonNull` annotations for the compiled obj-c code too? If not, why?
    a
    • 2
    • 1
  • d

    Dariusz Rusin

    03/02/2020, 7:00 AM
    After updating to Android Studio 3.6.1 when I'm running tests they failed when trying find multiplatform classes:
    java.lang.NoClassDefFoundError
    s
    • 2
    • 1
  • o

    Orhan Tozan

    03/02/2020, 4:48 PM
    What needs to be put in the
    jvmMain
    sourceset for kotlin coroutines? Couldn't find anything at the README of the coroutines repo. Also, is there a reason why this doesn't come out-of-the-box? E.g. when I declare that I want to use kotlin coroutines in the project, it could automatically import the specific platform dependencies itself.
    k
    • 2
    • 6
  • m

    Mike

    03/02/2020, 5:54 PM
    Hi, I'm hitting extremely long compile times in a kotlin native mpp project during the compileKotlinJvm task. It takes around 10 minutes to build every time I modify something (I am using a very fast machine). I tried running a profiled build and think incremental build is broken for some reason. Has anyone hit similar issues? https://github.com/JetBrains/kotlin-native/issues/3933
    r
    • 2
    • 2
  • j

    Justin Shapiro

    03/02/2020, 7:24 PM
    Hi, I’m writing a library targeting android and js. I’ve got the aar. Are there examples of running a bundler on the js output?
    👀 1
    • 1
    • 2
  • e

    Eben Du Toit

    03/03/2020, 8:18 AM
    Hi, I wanted to find out if any of you guys know what the status is of #grpc for kotlin multiplatform?
    🙄 1
    ➕ 1
    👀 1
    s
    • 2
    • 6
  • a

    Arthur Brum

    03/03/2020, 1:45 PM
    Hi, Im getting some problems with kotlin coroutines.. I'm trying to use runBlocking in my common code. And since I don't have a JS target (which is the only target that do not accept runBlocking), it should be possible, right? is there a workaround not being through expect/actual implementations?
    🇳🇴 1
    s
    • 2
    • 3
  • n

    Nikita Khlebushkin

    03/03/2020, 2:00 PM
    Hello, is it possible to build for armv7? I'm running it from Xcode and it totally doesn't recognise my cocoapods KMP framework, although it bulds fine for arm64
    a
    • 2
    • 2
  • a

    Andreas Jost

    03/03/2020, 2:08 PM
    Hi, is there a way to express hierarchy with expect/actual in Multiplatform? Let's say you have an expected class
    ViewContainer
    , which is a typealias for
    View
    on Android-side and
    UIView
    on iOS-side. And an extension function
    ViewContainer.setVisibility(isVisible: Boolean)
    . And you also have a second expected class
    TextField
    , which is a typealias for Android
    EditText
    / iOS
    UITextField
    .
    EditText
    is a subclass of
    TextView
    , which is a subclass of
    View
    .
    UITextField
    is a subclass of
    UIControl
    , which is a subclass of
    UIView
    . So both are related to `View`/`UIView` (
    ViewContainer
    ). It would be nice to tell that the compiler, so that you can invoke the function
    setVisibility()
    not only on
    ViewContainer
    , but also on
    TextField
    or other related classes. Obviously
    expect class TextField : ViewContainer
    won't work, because it isn't a direct child class. So one way is not having a hierarchy and copy/paste the same extension function with the same implementation to
    TextField
    and every View type. But shouldn't there be any better solution?
    a
    • 2
    • 2
Powered by Linen
Title
a

Andreas Jost

03/03/2020, 2:08 PM
Hi, is there a way to express hierarchy with expect/actual in Multiplatform? Let's say you have an expected class
ViewContainer
, which is a typealias for
View
on Android-side and
UIView
on iOS-side. And an extension function
ViewContainer.setVisibility(isVisible: Boolean)
. And you also have a second expected class
TextField
, which is a typealias for Android
EditText
/ iOS
UITextField
.
EditText
is a subclass of
TextView
, which is a subclass of
View
.
UITextField
is a subclass of
UIControl
, which is a subclass of
UIView
. So both are related to `View`/`UIView` (
ViewContainer
). It would be nice to tell that the compiler, so that you can invoke the function
setVisibility()
not only on
ViewContainer
, but also on
TextField
or other related classes. Obviously
expect class TextField : ViewContainer
won't work, because it isn't a direct child class. So one way is not having a hierarchy and copy/paste the same extension function with the same implementation to
TextField
and every View type. But shouldn't there be any better solution?
a

alex009

03/03/2020, 3:13 PM
https://github.com/mirego/trikot.metaviews may help
also if you want create screens and navigation from common code - you can check https://github.com/icerockdev/moko-widgets/
View count: 4