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

    Paulius Ruminas

    01/28/2019, 4:43 PM
    Hello, after update from gradle 4.7 to gradle 4.10 the ios framework module name changes With gradle 4.7:
    framework module common {
        umbrella header "common.h"
    
        export *
        module * { export * }
    }
    With gradle 4.10
    framework module main {
        umbrella header "main.h"
    
        export *
        module * { export * }
    }
    Can I specify an argument that would generate the previous module that was
    common
    instead of
    main
    ?
    j
    j
    y
    • 4
    • 5
  • j

    josephivie

    01/28/2019, 11:40 PM
    Does anyone know of a multi-platform way to create an instance of an annotation at runtime? As far as I can tell, there is none.
    o
    j
    • 3
    • 4
  • r

    ribesg

    01/29/2019, 9:01 AM
    When I refresh my Gradle project, it seems to download some poms and “build model” of a lot of Kotlin/Native dependencies every single time and it’s very long, is there a way to work around this?
    c
    y
    d
    • 4
    • 5
  • t

    timm

    01/29/2019, 10:18 AM
    I managed to make publishing work in my multiproject setup. But theres still an error. I have one java-subproject that has a dependency (
    project(":multiplatform-library")
    ) on the multiplatform project. When generating poms for publication a
    dependency
    entry for
    multiplatform-library
    is generated. It should generate a
    dependency
    entry on
    multiplatform-library-jvm
    though. Is there a way to fix this?
    y
    • 2
    • 1
  • y

    yshrsmz

    01/29/2019, 1:35 PM
    btw I’ve managed to publish mpp library to bintray without bintray plugin. https://github.com/yshrsmz/kgql/
    v
    • 2
    • 3
  • n

    nestserau

    01/29/2019, 1:45 PM
    I’ve started getting this error after I switched to 1.3.20 plugin:
    > Task :compileKotlinIos
    warning: skipping /Users/[me]/.gradle/caches/modules-2/files-2.1/io.ktor/ktor-client-ios_debug_ios_x64/1.0.0/356fffd211e215e1625368473e25ce844a378845/ktor-client-ios.klib. The abi versions don't match. Expected '[5]', found '2'
    warning: the compiler versions don't match either. Expected '[1.1.1]', found '1.0.2-release-4769'
    Any way to address it?
    👍 1
    c
    • 2
    • 6
  • r

    ribesg

    01/29/2019, 2:38 PM
    When I run
    compileKotlinIosArm64
    , it doesn’t even find the dependencies of `commonMain`:
    // Somewhere in a commonMain file
    import io.ktor.client.HttpClient
           ^
    My `build.gradle.kts`: https://gist.github.com/Ribesg/d76208f8d921cb22b50347e87014c144
    y
    n
    • 3
    • 36
  • d

    Damiano Giusti

    01/29/2019, 4:08 PM
    Here’s the
    targets
    block of my
    build.gradle
    targets {
            final def iOSPreset = System.getenv('SDK_NAME')?.startsWith("iphoneos") ? presets.iosArm64 : presets.iosX64
    
            fromPreset(iOSPreset, 'iOS') {
                compilations.main.outputKinds('FRAMEWORK')
            }
    
            fromPreset(presets.jvm, 'android')
        }
    d
    • 2
    • 12
  • d

    Damiano Giusti

    01/29/2019, 4:46 PM
    To whom will be interested, I managed to solve this problem by adding the
    com.android.libray
    plugin, allowing the
    kotlin-multiplatform
    plugin create the
    presets.android
    extension. You’ll need to create a
    main
    folder in your source root and add a valid AndroidManifest file, specifying the package name that will be used
    👍 3
    r
    • 2
    • 2
  • r

    Robert

    01/29/2019, 9:27 PM
    There is no way to get the users Locale in mpp, is there? Other then asking 😛
    d
    r
    j
    • 4
    • 6
  • j

    josephivie

    01/30/2019, 12:47 AM
    I have a multiplatform UI library I’m going to be releasing soon. Currently, it uses a data binding system that uses this interface:
    interface ObservableProperty<T> {
        val value: T
        /**
         * Adds a listener to be notified when the value changes.
         */
        fun add(element: (T) -> Unit): Boolean
        /**
         * Removes a listener
         */
        fun remove(element: (T) -> Unit): Boolean
    }
    I can either leave this data binding system in place, or I could replace it with
    ConflatedBroadcastChannel
    from Kotlin Coroutines, which while experimental, does already exist. I’d like your opinions on which I should choose.
    r
    j
    +2
    • 5
    • 5
  • y

    yshrsmz

    01/30/2019, 6:52 AM
    Anyone here experiencing slow code completion while editing kotlin/native code in IDEA? There is always some lag, and especially slow if I use functions from platform.darwin.
    ➕ 2
    l
    • 2
    • 3
  • t

    Tzahi Moyal

    01/30/2019, 9:06 AM
    Hi I’m trying to add GSON dependency, did someone did it before?
    r
    y
    • 3
    • 5
  • p

    Paulius Ruminas

    01/30/2019, 11:04 AM
    Hello, did anyone try to convert kotlin channels into rxswift streams? Or how one should use kotlin channels in swift since the compiler does not expose suspending functions (receive)?
    k
    a
    g
    • 4
    • 6
  • n

    nestserau

    01/30/2019, 2:10 PM
    So I’ve found a way to rename my iOS framework from
    main
    to a custom name of mine. But how should I adjust the
    packForXCode
    task? I don’t understand. Can someone guide me? That’s my iOS target:
    final def iosTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") ? presets.iosArm64 : presets.iosX64
            fromPreset(iosTarget, 'ios') {
                binaries {
                    framework {
                        baseName = 'reports'
                    }
                }
            }
    s
    y
    d
    • 4
    • 17
  • g

    galex

    01/30/2019, 2:23 PM
    When I put kapt() the dependencies block of a sourceset I get the following error: Could not find method kapt() for arguments [project ‘:processor’] on object of type org.jetbrains.kotlin.gradle.plugin.mpp.DefaultKotlinDependencyHandler.
    a
    • 2
    • 6
  • r

    ribesg

    01/30/2019, 2:24 PM
    So I’ve been stuck on this for a few days right now. I’m using Gradle 5.1.1 and Gradle Kotlin DSL, trying to build an iOS framework from just my common source set, not much. It doesn’t find any dependencies. Gist with code & debug build logs: https://gist.github.com/Ribesg/d76208f8d921cb22b50347e87014c144 I’m about to give up
    b
    • 2
    • 7
  • e

    egorand

    01/30/2019, 3:10 PM
    finally managed to migrate Okio to the new MPP plugin and Kotlin 1.3.20! there’s tons of trial and error in this PR: https://github.com/square/okio/pull/544
    🔥 4
    👍 5
    😍 1
    j
    • 2
    • 2
  • g

    GarouDan

    01/30/2019, 6:54 PM
    If we have the following in our sourceSet
    sourceSets {
    		jvmMain {
    			kotlin.srcDirs "src/main/kotlin"
    			resources.srcDir "src/main/resources"
    			
    			...
    		}
    where we are changing the dirs for the jvm target, how can we do the same for the tests folder? I tried some variations like this one:
    kotlinTest.srcDirs "src/main/test"
    testResources.srcDir "src/test/resources"
    but it didn’t work. Is there a doc or a place where I can find the available options?
    d
    • 2
    • 3
  • g

    GarouDan

    01/30/2019, 11:52 PM
    Good evening guys = ) Is it possible to have a mpp module without any presets / targets? My motivation to this is that I would like to create a common module without any targets / presets, just source sets, and them, in other modules, add this as a dependency. For example in desktop, mobile or backend modules. So I could use something like:
    implementation project(':common')
    If I put at least one preset / target it seems to work, but without any preset / target it isn’t working. Do you know if we can change our
    build.gradle
    to achieve this result?
    h
    n
    r
    • 4
    • 14
  • n

    nestserau

    01/31/2019, 9:18 AM
    I have a question about published Android artifacts. In my Archiva repo I have now
    reports-android
    and
    reports-android-debug
    groups. When I look at the artifcats, the AAR of the debug version takes 139K op space while the AAR of the release version from
    reports-android
    is only 691b. I looked inside, no classes are in there. Is it the way it’s supposed to be or anything is wrong here?
    r
    • 2
    • 5
  • n

    nestserau

    01/31/2019, 10:38 AM
    When I added my MPP library to an Android project as a dependency, I started getting
    More than one file was found with OS independent path
    when trying to build it. Googled it up a little bit, and came up with this workaround (to be placed in the
    build.gradle
    of the library consumer):
    android {
            packagingOptions {
                 pickFirst 'META-INF/ktor-http.kotlin_module'
                 pickFirst 'META-INF/kotlinx-io.kotlin_module'
                 pickFirst 'META-INF/atomicfu.kotlin_module'
                 pickFirst 'META-INF/ktor-utils.kotlin_module'
                 pickFirst 'META-INF/kotlinx-coroutines-io.kotlin_module'
                 pickFirst 'META-INF/ktor-client-core.kotlin_module'
        }
    }
    Now the compiler is happy. But is there no other solution? Not a deal breaker for me, but would like to address the core of the issue instead of having this floppy workaround.
    r
    y
    h
    • 4
    • 11
  • a

    Aleksey Kornienko

    01/31/2019, 5:06 PM
    Hello, maybe I do something incorrect, but I can’t run unit test in multiplatform project for Android. For example:
    class AnalyticsTest {
        private lateinit var context: Context
    
        @Before
        fun setUp() {
            context = InstrumentationRegistry.getInstrumentation().targetContext
        }
    
        @After
        fun tearDown() {
        }
    }
    The error I get
    java.lang.IllegalStateException: No instrumentation registered! Must run under a registering instrumentation.
    It doesn’t work only in multiplatform project
    y
    r
    • 3
    • 11
  • y

    yshrsmz

    02/01/2019, 11:00 AM
    For those who want BuildConfig for Kotlin MPP. I'm currently working on this https://github.com/yshrsmz/BuildKonfig
    👍 4
    💯 4
    d
    n
    +2
    • 5
    • 8
  • a

    addamsson

    02/01/2019, 3:42 PM
    How can I run tests annotated with
    kotlin.test.Test
    from the IDE in my
    commonTest
    module? IDEA doesn't recognize them as tests. Note that I'm using the
    kotlin-multiplatform
    plugin.
    n
    a
    • 3
    • 18
  • b

    basher

    02/01/2019, 4:41 PM
    Are there any examples out there of wrapping a cpp object and properly calling a cpp destructor when the kotlin object wrapping it is destroyed?
    s
    d
    o
    • 4
    • 15
  • j

    josephivie

    02/01/2019, 5:28 PM
    I have a bare-bones multiplatform client networking library. Does anyone need it, or can I drop it in favor of Ktor? I really want to switch to Ktor, but I’ll keep Kommunicate around if anyone sees a purpose in it.
    n
    • 2
    • 1
  • t

    Tzahi Moyal

    02/03/2019, 11:18 AM
    Hi, did someone try kotlinx.serialization with iOS?
    t
    • 2
    • 3
  • g

    GarouDan

    02/03/2019, 3:54 PM
    Hi guys, I asked this question on stackoverflow and I’ll appreaciate if someone could help me to find a workaround for this. https://stackoverflow.com/questions/54503916/is-it-possible-to-create-a-kotlin-multiplatform-project-referencing-the-correct I would like to know if this is a limitation or if we could change our configuration files to achieve the expected result.
    e
    d
    • 3
    • 10
  • d

    drofwarcs

    02/04/2019, 12:10 AM
    how do we expose dependencies brought in with cinterops to a test configuration?
    o
    r
    i
    • 4
    • 8
Powered by Linen
Title
d

drofwarcs

02/04/2019, 12:10 AM
how do we expose dependencies brought in with cinterops to a test configuration?
In my MPP project I'm bringing in ocmockito this way:
fromPreset(iosPreset, 'ios') {
            binaries {
                framework()
            }
            compilations.main {
                def productsDir = new File("").absolutePath
                linkerOpts "-F${productsDir}/common/libs"
                cinterops{
                    ocmockito {
                        includeDirs "${productsDir}/common/libs/OCMockitoIOS.framework/Headers"
                    }
                }
            }
        }
But I keep getting
error: unresolved reference: ocmockito
when I go to build the project
I had this working before updating to 1.3.20
o

orangy

02/04/2019, 5:49 AM
@ilya.matveev
d

drofwarcs

02/04/2019, 6:23 AM
found a fix. Changing
compilations.main
to
compilations.all
seem to get me pass that issue.
👍 1
r

russhwolf

02/04/2019, 12:52 PM
I think
compilations.test
would work if you only need it for tests
i

ilya.matveev

02/04/2019, 2:25 PM
I think
compilations.test
would work if you only need it for tests
This is right. Also the
linkerOpts
property of a compilation affects only binaries created using the
compilation.outputKinds
method. If you declare a binary using the binaries DSL, you need to use
linkerOpts
of this binary:
binaries {
    framework {
        linkerOpts += ["-F${productsDir}/common/libs"]
    }
}
d

drofwarcs

02/04/2019, 2:32 PM
Sorry all, I found the steam of my issue. While updating to 1.3.20, I accidentally deleted the
packageName
of ocmockito under cinterops. Yesterday I had started out with
compilations.test
but when that failed I went to
compilations.main
thinking that the test compilations was wrong. the error
error: unresolved reference: ocmockito
was right all alone, I had just overlooked a simple detail. Thanks again for all of your help @svyatoslav.scherbina @russhwolf
👍 1
View count: 3