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

    pardom

    02/21/2019, 3:09 PM
    Is there a more up-to-date guide on multiplatform than this? https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html
    ☝️ 3
    r
    k
    • 3
    • 4
  • d

    Dico

    02/21/2019, 10:06 PM
    Does anyone know how I could go about using both IntelliJ and CLion on the same project? They seem to interfere with eachother because they share the same
    .idea/
    folder. A project with JVM targets as well as native targets where you want to debug the application is the subject.
    ➕ 1
    n
    • 2
    • 1
  • j

    josephivie

    02/22/2019, 3:27 AM
    When attempting to publish the Android side of a multiplatform library using
    publishLibraryVariants("release")
    , I keep getting
    org.gradle.api.UnknownDomainObjectException: KotlinJvmAndroidCompilation with name 'release' not found.
    . If I attempt to create one manually in the line above using
    compilations.create("release")
    , it gives
    Cannot add a KotlinJvmAndroidCompilation with name 'release' as a KotlinJvmAndroidCompilation with that name already exists.
    If I just read the compilations before hand, I can see that there are none. Can anyone help? I've been investigating this for a couple hours now
    h
    • 2
    • 3
  • a

    altavir

    02/22/2019, 9:03 AM
    I am still struggling with bintray publication. I think that I am close, but now I have the following error:
    class org.jetbrains.kotlin.gradle.plugin.mpp.HierarchyAttributeContainer cannot be cast to class org.gradle.api.internal.attributes.AttributeContainerInternal
    for both JVM and JS metadata generation. Where does it come from?
    • 1
    • 2
  • r

    ribesg

    02/22/2019, 9:24 AM
    Is there a way to make a Kotlin class implement the Swift
    Error
    protocol in the ios part of my MPP project? NOT
    NSError
    s
    • 2
    • 14
  • s

    Sabrina Namur

    02/22/2019, 10:47 AM
    Hey guys. I use the MVP pattern for my mpp and I am curious, if you also use a pattern, which and why? From kotlin/jetBrains is as far as I know no pattern recommended, right?
    o
    • 2
    • 1
  • d

    Diego

    02/22/2019, 2:46 PM
    Hello guys, I have function in common that returns
    ByteArray
    but on the iOS world it is converted to
    KotlinByteArray
    and not to
    NSData
    . In the Kotlin world I have the following extensions to convert
    ByteArray
    to
    NSData
    and visceversa.
    private fun ByteArray.toNSData(): NSData = memScoped {
        return NSData.create(
            bytes = toCValues().getPointer(this),
            length = size.toUInt()
        )
    }
    
    private fun NSData.toByteArray(): ByteArray = memScoped {
        val size = length.toInt()
        val nsData = ByteArray(size)
        memcpy(nsData.refTo(0), bytes, size.toUInt())
        return nsData
    }
    Does someone know how I can convert
    KotlinByteArray
    to
    NSData
    and visceversa in Swift? 🙂
    r
    j
    • 3
    • 4
  • n

    natpryce

    02/22/2019, 5:11 PM
    https://youtrack.jetbrains.net/issue/KT-30088
    g
    • 2
    • 5
  • k

    kpgalligan

    02/22/2019, 6:09 PM
    A question for intellij integration. For various target platforms (ios/macos, linux, androidNative), they’re all distinct with regards to “platform” and Native, but when building a library that publishes to these platforms, you’ll really want a common source set for that platform. For example, ios and macos all have “Foundation”, and they would all use it the same way. I define a source set for “apple” that each target’s source set depends on, and that builds fine, but intellij can’t resolve that. Is there a way to configure that to work as expected? I think it would be more like a hint to the IDE that didn’t really impact the compile build (something like “config as if iosArm64"). I’ve done this in the past by having a commented section in the build.gradle that gets uncommented to refresh gradle in Intellij, then commented out again, but that’s pretty ugly.
    r
    h
    +2
    • 5
    • 14
  • o

    orangy

    02/22/2019, 10:08 PM
    Yes, we are working on it, albeit slowly…
    s
    b
    c
    • 4
    • 5
  • j

    juancho

    02/23/2019, 3:18 AM
    l
    • 2
    • 4
  • l

    louiscad

    02/23/2019, 1:24 PM
    Hi, is there a way to disable the `metadata`/`kotlinMultiplatform` maven publication for a module in a project where gradle metadata is enabled otherwise?
    s
    d
    • 3
    • 11
  • b

    basher

    02/24/2019, 1:40 AM
    Is there a way to add compiler options in your build.gradle that apply to all test targets?
    r
    • 2
    • 5
  • n

    Nikky

    02/24/2019, 6:32 AM
    is it possible to add custom cofigurations that extend implementation or api on multiplatform?
    j
    • 2
    • 1
  • o

    orangy

    02/24/2019, 9:23 PM
    working on mpp file system, yes
    🎉 13
    r
    j
    +3
    • 6
    • 30
  • d

    darkmoon_uk

    02/25/2019, 2:48 AM
    I want to build a multi-platform library with separate platform-specific source-sets for Android Mobile and JavaFX Desktop. Since both of these would fall under the default
    jvmMain
    source set - I'm assuming I want to define additional JVM targets to separate the Android/JavaFX dependencies (e.g.
    androidMain
    and
    javafxMain
    and avoid using
    jvmMain
    to avoid ambiguity) ? Can anyone confirm this the way to go + any caveats/suggestions?
    r
    g
    • 3
    • 2
  • n

    natpryce

    02/25/2019, 1:43 PM
    If I create a Gradle build script for an multiplatform Kotlin project (with no source, just the project structure) and import it into IntelliJ, IntelliJ thinks that the packages in the Kotlin source directories are Python packages, and the New popup smenu on common source directories only offer the option to create new Python packages, not Kotlin packages. Is this a known bug? I’m using the latest IntelliJ and Kotlin plugin. I also have the Python plugin installed.
    l
    • 2
    • 2
  • s

    spand

    02/25/2019, 1:53 PM
    Is it possible to fulfill the companion object of something typealiased to a java type? ie.
    expect class Foo {
        companion object {
            fun of() : Foo
        }
    }
    
    actual typealias Foo = java.lang.String
    a
    i
    • 3
    • 10
  • s

    serebit

    02/25/2019, 6:09 PM
    you need to apply the mpp plugin in
    ios.gradle.kts
    as well
    b
    • 2
    • 5
  • k

    Kris Wong

    02/25/2019, 10:44 PM
    this probably doesn't understand Android libraries, does it
    :thread-please: 1
    y
    n
    • 3
    • 3
  • j

    juancho

    02/26/2019, 3:42 AM
    Hi all! I have a question regarding
    Exceptions in Multiplatform
    (for the JVM target). I have a multiplatform lib with a method that can throw a custom exception. In Java code I’m using that method surrounded with a try/catch. I was expecting that custom exception to arrive but it was not working. I just added another catch with a general
    Throwable
    exception, now it worked and also what got my attention is that it’s a
    RuntimeException
    where the
    cause
    has my CustomException, so I can access it from there but it’s kind of annoying. Does anyone know how to improve this? So it looks like this:
    try {
                return mppApi.getSomethingWithExceptionInMultiplatform();
            } catch (MyCustomException e) {
                // never gets here...
            } catch (Throwable e) {
                if (e.getCause() instanceof MyCustomException) {
                    // here I can access my custom exception fields with
                    // ((MyCustomException) e.getCause())
                }
                throw e;
            }
    j
    n
    • 3
    • 5
  • g

    galex

    02/26/2019, 10:16 AM
    Where did my R.java go when having a sourceset android() ?
    r
    • 2
    • 5
  • r

    ribesg

    02/26/2019, 11:13 AM
    We have a MPP library (Project A) which has a dependency on a Swift Framework (Bugsnag-cocoa) on the iOS side, setup with cinterops, published to a maven repo as a KLibrary. We’re trying to use it in an iOS app setup with a MPP project (Project B) whose goal is to create a Framework with all MPP dependencies for the XCode project. We get the following error when building the Framework (Project B):
    > Task :linkReleaseFrameworkIos
    ld: framework not found Bugsnag
    l
    s
    i
    • 4
    • 25
  • k

    Kris Wong

    02/26/2019, 4:28 PM
    is it possible to load a text file resource in a unit test from the 'jvmTest' source set? javaClass.getResource("/filename") does not seem to be working.
    d
    • 2
    • 7
  • n

    nestserau

    02/26/2019, 4:38 PM
    A question about publishing fat iOS frameworks to a Maven repository. So I can successfully publish Android artifacts to a Maven repository (namely, Archiva). I need to also add iOS debug and release fat frameworks to the list of artifacts along with the already published
    klib
    under the
    ios
    category. I build my fat frameworks using this code: https://gist.github.com/benasher44/32f602b9d5ec596ceaa3c9d190b14fc9 Kudos to @basher Further I’ve added a couple of extra tasks to create a zip to be consumed by CocoaPods:
    task("zipIos${config}Artifacts", dependsOn: "createIos${config}Artifacts", group: "iOS", type: Zip) {
                archiveFileName = "${rootProject.name}${"debug".equalsIgnoreCase(config) ? '-debug' : ''}.zip"
                destinationDirectory = file("$outputDir/..")
                from outputDir
            }
    And now I’m stuck. How do I tell the
    maven-publish
    plugin to also include the artifacts produced by
    zipIosDebugArtifacts
    and
    zipIosReleaseArtifacts
    tasks? If I read these docs https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#publishing-a-multiplatform-library it concerns configuring targets, but that’s not something that is useful for me, since my artifact is a result of multiple targets.
    • 1
    • 1
  • p

    pardom

    02/26/2019, 4:38 PM
    https://kotlinlang.slack.com/archives/C1CFAFJSK/p1551199064120900
    b
    n
    +2
    • 5
    • 14
  • l

    louiscad

    02/27/2019, 6:23 AM
    Did anyone succeed in publishing a multiplatform library using Gradle 5.2.1 and Kotlin 1.3.21? I'm consistently getting the following error:
    Execution failed for task ':modules:name-of-my-module:generateMetadataFileForJvmPublication'.
    > org.jetbrains.kotlin.gradle.plugin.mpp.HierarchyAttributeContainer cannot be cast to org.gradle.api.internal.attributes.AttributeContainerInternal
    (I also reported it here: https://youtrack.jetbrains.com/issue/KT-30158?project=kt)
    d
    a
    r
    • 4
    • 23
  • n

    natpryce

    02/27/2019, 8:26 AM
    On the JVM platform, the org.w3c.dom API is defined as interfaces (e.g.
    public interface Document extends Node
    ). On the JS platform it is defined as abstract classes (e.g.
    public external open class Document : Node, ...
    ). This makes it impossible to write multiplatform code that uses DOM elements, and also impossible to write expect/actual declarations for DOM elements in common code. Is there a workaround or other API that can be used to work with XML in multiplatform projects?
    i
    • 2
    • 1
  • j

    josephivie

    02/27/2019, 9:10 AM
    I am exhausted. After almost a month of working on nothing but upgrading build scripts and preparing for releasing to open source, I present KoolUI: the poorly-named multiplatform UI system, supporting Android, Web, JavaFX, and hopefully soon iOS. I could use any help anyone is willing to give. There's a lot of documentation to do yet, but there is a test project in the source that demonstrates how it works. https://github.com/lightningkite/koolui
    🎉 11
    😕 1
    👍 6
    😱 3
    g
    a
    p
    • 4
    • 8
  • b

    basher

    02/27/2019, 6:05 PM
    Has anyone run into `java.lang.NoClassDefFoundError`s when trying to run tests from
    commonTest
    on JVM/Android? One class is an expect/actual class. The other is an
    object
    . Both are in
    commonMain
    • 1
    • 1
Powered by Linen
Title
b

basher

02/27/2019, 6:05 PM
Has anyone run into `java.lang.NoClassDefFoundError`s when trying to run tests from
commonTest
on JVM/Android? One class is an expect/actual class. The other is an
object
. Both are in
commonMain
This was just a dependency issue I was having trouble seeing
View count: 2