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

    louiscad

    03/07/2019, 12:51 AM
    Hi, does anyone know how to tell the Android Gradle Plugin to use content and dependencies of the
    androidMain
    sourceSet from Kotlin multiplatform plugin in an
    androidTest
    sourceSet (instrumented test)? My
    build.gradle.kts
    includes the following:
    android {
        setDefaults()
        sourceSets.getByName("androidTest").java.srcDir("src/androidInstrumentedTest/kotlin") // I put my instrumented tests here.
    }
    kotlin {
        android()
        sourceSets {
            getByName("androidMain").dependencies {
                // Some dependencies here
            }
        }
    }
    dependencies {
        androidTestImplementation(Libs.kotlin.testJunit)
        androidTestImplementation(Libs.androidX.test.coreKtx)
        androidTestImplementation(Libs.androidX.test.ext.junit)
        androidTestImplementation(Libs.androidX.test.runner)
        androidTestImplementation(Libs.kotlinX.coroutines.android)
    }
    The problem I encounter is that it compiles, but when an instrumented test is run, there's
    NoClassDefFoundError
    on anything defined in
    androidMain
    (be it source or dependency). Note that the IDE shows no warning and allows me to use the dependencies from
    androidInstrumentedTest
    , but it fails at runtime.
    g
    n
    • 3
    • 2
  • c

    carlos cdmp

    03/07/2019, 12:44 PM
    Any updated multiplatform project with Android, IOS, and web to check on github? I want to start a project, so i would like to have a nice example
    o
    d
    s
    • 4
    • 7
  • p

    pardom

    03/07/2019, 3:06 PM
    I’ve encountered an issue when using Coroutines in mpp. The Obj-C header errors on the following line:
    @property (class, readonly) CounterCoreCoroutineStart *default;
    👍 1
    r
    o
    • 3
    • 7
  • j

    Jaroslav

    03/08/2019, 11:22 AM
    Is there any easy way to debug
    kotlin.NotImplementedError: An operation is not implemented: Not implemented
    ? I`m using kotlin library in ios, with a lot of code, so it will take me a lot of time to find what exactly is not implemented 😞
    m
    g
    • 3
    • 6
  • p

    pardom

    03/08/2019, 2:52 PM
    Hey, all. I’m getting a
    kotlin.TypeCastException
    that I’m hoping you all can help with. In order to get around generics and casting issues in K/N, I’ve quarantined a call to a generic function to the common Kotlin code in an mpp project: https://github.com/pardom/oolong/pull/16/files#diff-b6307a0524635d6d8940c58b27823806R48. This fixes the compiler errors in Swift, however it fails at runtime due to casting. Any ideas why?
    o
    • 2
    • 2
  • p

    pardom

    03/08/2019, 3:00 PM
    Also, do type aliases to functions not get exported to K/N? I can’t reference any in the consuming project.
    o
    l
    • 3
    • 3
  • g

    GarouDan

    03/08/2019, 3:22 PM
    Hi, it looks like we have a problem when integrating the
    kotlin("multiplatform")
    and spring boot. I’ve filed an issue about that here: https://youtrack.jetbrains.com/issue/KT-30340 I was talking with the folks in the spring boot gitter chat and they said:
    but I would guess that, unlike, the JVM platform plugin, it doesn't apply Gradle's Java plugin
    If someone knows how to fix this please tell me 😃
    b
    a
    • 3
    • 4
  • p

    pardom

    03/08/2019, 4:00 PM
    Is there any documentation on K\N generic function interop? There’s nothing in here https://github.com/JetBrains/kotlin-native/blob/master/OBJC_INTEROP.md#function-types
    s
    k
    • 3
    • 6
  • a

    Andrey Gromov

    03/09/2019, 3:33 PM
    Hello! I create new multiplatform prject (android/ios) by Idea wizard. After that I add Ktor, step by step from manual. For android and common part all is ok, but iosMain does not see "import kotlinx.coroutines.*" at all. How to add ktor/coroutines to iosMain correctly? RESOLVED Inserting
    enableFeaturePreview("GRADLE_METADATA")
    into settings.gradle resolve problem. 7 f**g hours dancing with tambourine...
    p
    • 2
    • 1
  • p

    pardom

    03/10/2019, 1:36 AM
    Does someone have an example of packaging a
    js
    target for npm? I thought I saw one somewhere but I don’t remember where.
    g
    • 2
    • 2
  • t

    Trevor Stone

    03/11/2019, 4:44 AM
    Hey! Has anyone else ran into an issue where multiplatform code is showing up as a missing import in Android Studio/IntelliJ, but the code still compiles and runs fine? I am trying to use it just as a jvm library but consumed inside of an android app. There are multiple kotlin multiplatform modules that are dependencies of each other as well. Everything seems to work fine except for the IDE integration
    j
    • 2
    • 2
  • g

    gumil

    03/11/2019, 9:58 AM
    Is using
    kotlin-platform-common
    already deprecated? should we just use the `multiplatform`plugin? I can’t find documentation on
    kotlin-platform-common
    r
    a
    • 3
    • 4
  • r

    Riccardo Montagnin

    03/12/2019, 6:42 AM
    Hello everyone. Is it possible to run the tests inside
    commonTest
    without any
    jvm
    or other module? If I try to run
    gradle check
    I get the following error:
    > Task :compileKotlinJvm 
    
    e: ...: Unresolved reference: Json
    Where
    Json
    is imported as
    import kotlinx.serialization.json.Json
    And my dependencies are the following:
    kotlin.sourceSets {
        commonMain.dependencies {
            api "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serialization_version"
        }
    }
    s
    s
    • 3
    • 5
  • p

    pajatopmr

    03/12/2019, 1:31 PM
    I have not a clue what that means or how to resolve it. Any help?
    d
    a
    • 3
    • 6
  • m

    Marc Knaup

    03/12/2019, 3:42 PM
    multiple failures 😅
    r
    • 2
    • 2
  • b

    basher

    03/12/2019, 4:37 PM
    I have a sealed class, and as soon as I made it internal, I got these warnings when linking the test executable that tests the inline functions of that class:
    warning: inliner failed to obtain function declaration: <package>.<class>.<function>
    Has anyone run into this before?
    r
    • 2
    • 3
  • j

    jw

    03/13/2019, 12:26 AM
    Did you try JvmName?
    m
    • 2
    • 1
  • p

    Patrick Jackson

    03/13/2019, 2:02 PM
    Are top level variables initialized differently in kotlin native? I have code that runs on jvm fine, but in native I get a bad_access for a val. Given: class A(private var b: B) { fun foo() { b.bar() } } val b = B() val a = A(b) I will get a bad_access (null pointer) on the instance of b when calling b.bar() in foo(). Changing a to use
    by lazy
    fixes the problem.
    o
    • 2
    • 4
  • p

    pajatopmr

    03/13/2019, 6:02 PM
    How do test resources get moved such that they will be accessible via
    classLoader.getResource("foo.txt")
    during a test? And is the package relevant?
    k
    a
    • 3
    • 13
  • i

    ivan.savytskyi

    03/13/2019, 8:27 PM
    Hey folks, how to provide
    linkerOpts
    for compilation tests? in MPP project (MPP gradle plugin) If I do this:
    def iosPreset = findProperty("kn.ios.target") == "arm" ? presets.iosArm64 : presets.iosX64
            fromPreset(iosPreset, 'ios') {
                compilations.all {
                    kotlinOptions.freeCompilerArgs = ["-Xverbose-phases=linker"]
                    outputKinds('FRAMEWORK')
                    linkerOpts "-F./libs"
    I’m getting error
    llvm-lto: error: Linking globals named 'ktype:com.greeter.NSObjectProtocolMeta': symbol multiply defined!
    Is there any way I can provide
    linkerOpts
    for test compilation
    b
    • 2
    • 2
  • i

    ivan.savytskyi

    03/13/2019, 9:58 PM
    Another question (KN iOS), if I have 3rd party dynamic library (framework), how I can bundle it into the executable binary generated by
    linkTestDebugExecutableIos
    task (test.kexe). As if I run this kexe on the simulator obviously I get
    dyld: Library not loaded
    ?
    s
    • 2
    • 1
  • c

    Cyrille QUÉMIN

    03/14/2019, 6:55 PM
    I am now building the same project with
    1.3.30-eap-42
    , it used to build properly with kotlin
    1.3.20
    . Now it crashes when creating the test executable with this error:
    > Task :p2p-common:linkTestDebugExecutableIOS
    e: Compilation failed: null
    
     * Source files: ExtensionsTest.kt, P2PCommandMessageBuilderTest.kt, SerializationTests.kt
     * Compiler version info: Konan: 1.2-eap-8472 / Kotlin: 1.3.30
     * Output kind: PROGRAM
    
    e: kotlin.KotlinNullPointerException
    Kotlin_1_3_30-eap42_crash_ios_test_executable_build.txt
    s
    r
    • 3
    • 3
  • m

    Marc Knaup

    03/14/2019, 8:13 PM
    Anybody had any luck getting multiplatform composite builds working properly in IntelliJ? Compiles fine with Gradle but modules can't see each other in IntelliJ 😞
    ➕ 1
    r
    t
    l
    • 4
    • 9
  • p

    Patrick Jackson

    03/15/2019, 3:20 PM
    are
    object
    singletons treated like normal classes in kotlin native? specifically when accessing from iOS Swift? Seems like the responsibility of swift code to maintain the singleton instance unless I am missing something.
    r
    s
    • 3
    • 3
  • g

    galex

    03/15/2019, 6:32 PM
    Is sqldelight compatible with the new way of building an MP of
    kotlin-multiplatform
    gradle plugin? I keep seeing libraries using the
    org.jetbrains.kotlin.multiplatform
    plugin. Is it the same one as
    kotlin-multiplatform
    plugin?
    k
    j
    • 3
    • 8
  • g

    GarouDan

    03/15/2019, 6:41 PM
    Hi, When configuring a project with the
    kotlin("multiplatform")
    plugin we can do something like:
    val jvmMain by getting {
    ...
    }
    but how our build process knows that if we write
    jvmMain2
    in the variable name instead of
    jvmMain
    our sourceset does not exist? My motivation is that I would like to do something similar, probably using my
    buildSrc
    , but I don’t know which kind of magic we are using here. Is the kotlin build process somehow extracting the variable names and comparing them with the available sourcesets?
    r
    • 2
    • 2
  • d

    Dico

    03/16/2019, 12:18 PM
    If I have a multiplatform child project with 2 JVM targets, how can I select one target as a dependency in gradle?
    d
    l
    • 3
    • 32
  • m

    Marc Knaup

    03/16/2019, 3:36 PM
    Is there a library with a multiplatform
    Locale
    and/or
    Currency
    yet?
    i
    • 2
    • 1
  • g

    GarouDan

    03/16/2019, 7:23 PM
    Instead of use
    val mobileMain by creating {...}
    , can we put this result in a map, without creating a new
    val
    ? For example, something similar to:
    myMap["mobileMain"] by creating {...}
    (do not compile) My motivation is that I would like to create a helper method to store sourceSets in a map, since I would like to consult this map later. The
    creating
    delegation is using something like:
    operator fun provideDelegate(thisRef: Any?, property: KProperty<*>) = ExistingDomainObjectDelegate.of(
            when (configuration) {
                null -> container.create(property.name)
                else -> container.create(property.name, configuration)
            }
        )
    d
    • 2
    • 5
  • g

    gumil

    03/16/2019, 9:35 PM
    is there already a kotlin library with the new multiplatform plugin? I'm stuck with outputKinds for kotlin native KLIBRARY, which seems not an enum anymore in the new plugin
    d
    • 2
    • 14
Powered by Linen
Title
g

gumil

03/16/2019, 9:35 PM
is there already a kotlin library with the new multiplatform plugin? I'm stuck with outputKinds for kotlin native KLIBRARY, which seems not an enum anymore in the new plugin
d

Dominaezzz

03/16/2019, 9:43 PM
If you paste a snippet I can help you convert it. 🙂
Or you can look at https://github.com/Dominaezzz/kgl-vulkan-samples/blob/master/triangle/build.gradle.kts as a reference.
g

gumil

03/16/2019, 10:02 PM
main {
        kotlin.srcDirs = ['src/main/kotlin', '../common/src/main/kotlin', '../../json/common/src']

        component {

            baseName = "kotlinx-serialization-runtime-native"

            // todo: fixme, k/n!
            publishJavadoc = false
            publishSources = false

            outputKinds = [KLIBRARY]
            if (!deployMode)
                target 'host'
            else
                targets = [ 'ios_arm64', 'ios_arm32', 'ios_x64', 'macos_x64', 'linux_x64', 'mingw_x64' ]

            extraOpts experimentalsEnabled
        }
    }
i wanted something similar to this, with the
outputKinds = [KLIBRARY]
but KLIBRARY seems not an enum anymore.
d

Dominaezzz

03/16/2019, 10:04 PM
By default, each native target produces a
KLIBRARY
, if you don't specify any other type.
g

gumil

03/16/2019, 10:06 PM
ohh thanks! also, is KLIBRARY be able to publish on maven?
d

Dominaezzz

03/16/2019, 10:12 PM
Yup
g

gumil

03/16/2019, 10:17 PM
Is there a way to build native binaries for iOS that can run on a linux machine?
d

Dominaezzz

03/16/2019, 10:19 PM
Native binaries aren't cross platform.
You can build a linux executable or an iOS binary but they will only run on their respective platforms.
g

gumil

03/16/2019, 10:29 PM
the problem i'm having is CI can't build iOS artifacts because it's running linux
d

Dominaezzz

03/16/2019, 10:33 PM
Ohhh. You want to build iOS binaries on a linux machine. I thought you wanted to run them.
That's not possible at the moment.
You'll need to run the build on osx.
View count: 4