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

    drofwarcs

    02/04/2019, 6:38 AM
    After fixing the issue above, I ran into another related issue. when running the build task, I was getting
    ld: framework not found OCMockitoIOS
    which is a linker error. Updated my gradle script with linker options in the framework block like:
    framework {
          embedBitcode("disable")
          def productsDir = new File("").absolutePath
           linkerOpts = ["-F${productsDir}/common/libs"]
    }
    which points to the directory where that framework is located. This change gets me past the part where it failed before, but throws a new error
    error: compilation failed: Collection has more than one element.
    Am I using the wrong linker options or is this a bug in compiler?
    s
    • 2
    • 4
  • e

    Edouard Goossens

    02/04/2019, 2:35 PM
    Hi! Is it possible to publish multiplatform libraries (with GRADLE_METADATA enabled) to JitPack? If I understand correctly, JitPack relies on the build task, which doesn’t produce the .module files... Is there a way to get around this? Thanks!
    h
    • 2
    • 35
  • g

    galex

    02/04/2019, 3:27 PM
    Hello, I can compile and build a node (js) target with dependencies to ktor-client-js but it seems like a project depending on my node target build does not get its dependencies for ktor at runtime as I get errors like
    Module not found: Error: Can't resolve 'ktor-client-core'
    and
    Module not found: Error: Can't resolve 'ktor-http'
    . What am I expected to do to have those transitive dependencies taken care of?
    a
    • 2
    • 1
  • r

    raniejade

    02/04/2019, 9:29 PM
    Anyone else having a problem getting IDE support for a
    jvm
    only module depending on a
    mpp
    module? They are in the same project (
    implementation project('mpp-module)
    ). Classes in the
    mpp
    module can't be resolved by IJ in the
    jvm
    only module. Though, compiling with gradle works as usual.
    l
    • 2
    • 10
  • g

    galex

    02/05/2019, 7:24 AM
    Do we have a solution for localization? Like having common code that returns localized strings, with a single source of localized strings per language in common module?
    👍 1
    ➕ 1
    l
    r
    +2
    • 5
    • 10
  • t

    Tzahi Moyal

    02/05/2019, 7:31 AM
    Hi, I have Serializable class and I used kotlinx.serialization, did someone know how I can use it in iOS SWIFT? I’m trying to parse JSON with the class I’d created
    s
    • 2
    • 8
  • s

    sirrah

    02/05/2019, 7:56 AM
    I'm in the process of upgrading a Kotlin Multiplatform project to Kotlin 1.3.20. I quickly ran into the following error while linking the
    iosX64
    target:
    ld: '/Users/.../.konan/dependencies/libffi-3.2.1-2-darwin-ios_sim/lib/libffi.a(ffi64_x86_64.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture x86_64
    Which seems to be a result of bitcode being enabled by default in Kotlin 1.3.20. So I've tried disabling it for all my iOS targets by adding the following to each target:
    binaries {
       framework {
           embedBitcode('disable')
       }
    }
    Unfortunately this doesn't resolve the error. I'd appreciate any suggestions on what to try next?
    s
    i
    s
    • 4
    • 16
  • w

    wakingrufus

    02/05/2019, 2:07 PM
    hmm ok. well if anyone has a couple minutes to look over my setup, i would appreciate it: https://github.com/wakingrufus/text-adventure I am trying to get the jvm project
    my-game-jvm-terminal
    to depend on the mpp
    text-adventure-terminal
    and I am getting
    e: /home/rufus/code/text-adventure/my-game-jvm-terminal/src/main/kotlin/com/github/wakingrufus/mygame/Main.kt: (5, 5): Unresolved reference: playInTerminal
    i
    s
    • 3
    • 6
  • c

    coolcat

    02/05/2019, 3:26 PM
    Are there any up-to-date instructions on setting up an iOS/Android multiplatform project since the Kotlin 1.3.20 update? An equivalent of https://kotlinlang.org/docs/tutorials/native/mpp-ios-android.html My current issue: I want to rename the new default “main” iOS framework to a different one. When I add
    fromPreset(iOSTarget, 'iOS') {
                binaries {
                    framework {
                        baseName = 'myname'
                    }
                }
                compilations.main.outputKinds('FRAMEWORK')
            }
    I see
    myname.framework
    present in
    build/bin/iOS/debugFramework
    and
    releaseFramework
    . But the
    build/xcode-frameworks
    folder generated by the
    packForXCode
    task still contains
    main.framework
    . Should I now be pointing my Xcode project directly to
    build/bin/iOS/debugFramework
    and
    releaseFramework
    ? Or is it basically simplest to suck it up and rename the references in my iOS code to
    main
    instead of
    myname
    ?
    s
    b
    r
    • 4
    • 4
  • j

    josephivie

    02/05/2019, 4:47 PM
    I'm going to introduce several projects I've been working on for multiplatform. https://github.com/lightningkite/kommon - A collection of random tidbits that really should be part of the standard library https://github.com/lightningkite/reacktive - An observable property and signaling system for multiplatform, used in an upcoming UI library https://github.com/lightningkite/lokalize - A library for accessing locale information All are available through a specific JCenter repository as specified in the READMEs! I'd be happy to get PRs and any other help too.
    🎉 3
    a
    l
    r
    • 4
    • 56
  • g

    galex

    02/05/2019, 7:59 PM
    Do we have a way to build libraries in debug and release modes like in Android?
    d
    • 2
    • 2
  • g

    galex

    02/05/2019, 8:17 PM
    Another one, what’s the right engine configuration for ktor-client-js to be able to parse Json? In Android I could add the following: actual val networkHttpClient: HttpClient get() = HttpClient(OkHttp) { engine { if(BuildConfig.DEBUG) addNetworkInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY }) } install(JsonFeature) { serializer = GsonSerializer() } }
    d
    • 2
    • 2
  • r

    Robert

    02/05/2019, 9:40 PM
    Is it possible to implement a method
    insert
    (or
    prepend
    ) to the
    StringBuilder
    class? There already is
    append
    o
    • 2
    • 2
  • w

    wollnyst

    02/06/2019, 2:20 PM
    Is there a MPP XML parsing library? If not, how would you workaround? Not using XML is not an options 🙂
    s
    • 2
    • 1
  • w

    wakingrufus

    02/06/2019, 3:30 PM
    is there a way to make a jvm target in a MPP a "java application" a la the gradle java application plugin, or something similar? or is it better to create a separate jvm-only gradle subproject for just the application stuff? basically this would be similar to the
    binaries
    section of a native target
    h
    • 2
    • 2
  • j

    josephivie

    02/06/2019, 10:52 PM
    I've noticed that if you publish a library with Gradle Metadata, and then have another library depend on it that also uses Gradle Metadata, you must include the first library by its kotlinMetadata artifact as opposed to doing it individually target by target and anyone depending on the second library MUST use Gradle Metadata. Can anyone else confirm this?
    h
    • 2
    • 3
  • j

    josephivie

    02/06/2019, 11:08 PM
    Also, why do you all at JetBrains specifically disable it in many situations? I've seen things like this everywhere: https://github.com/Kotlin/kotlinx.serialization/blob/master/build.gradle#L173
    h
    • 2
    • 1
  • t

    Tzahi Moyal

    02/07/2019, 6:21 AM
    Hi, did someone try to open socket with multiplatform?
    t
    s
    • 3
    • 2
  • t

    thana

    02/07/2019, 8:15 AM
    i want to dependent on
    spring-boot-starter-web
    in
    jvmMain
    but want to exclude
    spring-boot-starter-tomcat
    a
    • 2
    • 3
  • s

    spierce7

    02/07/2019, 10:52 PM
    When are we going to see a Kotlin MPP date library? I had heard that this was on JetBrains radar, but haven't heard anything about this.
    i
    s
    +4
    • 7
    • 16
  • g

    GarouDan

    02/08/2019, 6:14 PM
    Hi guys, can we filter the packages to be considered inside of a source set? For example, are we able to do something like this?
    sourceSets {
    		val jvmMain by getting {
    			kotlin.srcDir("src/main/kotlin")
    			resources.srcDir("src/main/resources")
    			filterPackages("com.company.project.jvm") // filtering packages here
    		}
    My motivation is to try to join all sources in the same folder, for example
    src/main/kotlin
    . If we are to do this we could create some packages like:
    com.company.project.common
    ,
    com.company.project.js
    ,
    com.company.project.jvm
    Where all of them could be inside the
    src/main/kotlin
    .
    😱 1
    ➖ 1
    d
    • 2
    • 4
  • o

    orangy

    02/09/2019, 1:10 PM
    At this stage there are no right or wrong ideas, I believe. They are all experimental, and what matter is which ideas work well, and which doesn’t. As an example, a big design question for a multiplatform FileSystem is how compatible with JVM (nio) it should be. Can you pass
    Path
    object as if it is
    nio
    instance (essentially, an actual typealias), or you have to do
    toJavaPath
    ? Being compatible is nice, but it comes at a cost of non-idiomatic APIs, and then limiting what other platforms (JS, Native) can do.
    j
    • 2
    • 3
  • v

    vpriscan

    02/09/2019, 2:24 PM
    Hello everyone. I am trying to set up kotlin multiplatform for jvm and android targets (server/client). when I first tried to build it with Intellij IDEA, it was built successfully, but after doing something to .idea folder, I am now constantly getting
    Error:Kotlin: Unsupported plugin option: org.jetbrains.kotlin.android:enabled=true
    when trying to build the project. I tried removing .idea and all .iml files but no luck. Please help!
    i
    d
    • 3
    • 3
  • t

    tvede

    02/09/2019, 4:15 PM
    Hello everyone; so a quick question; is there any way that IDEA can provide Unit code coverage for a multiplatform library ? it seems like any way i try run with coverage (from idea) results in it never actually taking the common library code into account..
    a
    i
    • 3
    • 14
  • v

    vpriscan

    02/09/2019, 4:29 PM
    how to apply application plugin only to jvm target
    i
    • 2
    • 2
  • j

    jw

    02/09/2019, 5:46 PM
    It isn't
    k
    d
    • 3
    • 18
  • a

    addamsson

    02/09/2019, 6:18 PM
    What I'm really looking forward to is a thorough guide for the
    kotlin-multiplatform
    plugin which includes Dokka and Maven Central deployment
    i
    • 2
    • 23
  • a

    addamsson

    02/09/2019, 6:21 PM
    what I really miss from Maven ever since I started using Gradle is the effective pom
    i
    d
    • 3
    • 13
  • j

    josephivie

    02/09/2019, 6:29 PM
    That said, it's still better than anything else I know of at its job. I just wish they would have had Kotlin when they started.
    a
    i
    k
    • 4
    • 26
  • r

    russhwolf

    02/11/2019, 4:26 AM
    Can I always assume sources named
    commonMain
    and
    commonTest
    will be present in
    project.kotlin.sourceSets
    ? If not, is there a way to dynamically detect the common sources? I was looking at the
    metadata
    target but it only has a
    main
    compilation and no
    test
    .
    j
    g
    h
    • 4
    • 8
Powered by Linen
Title
r

russhwolf

02/11/2019, 4:26 AM
Can I always assume sources named
commonMain
and
commonTest
will be present in
project.kotlin.sourceSets
? If not, is there a way to dynamically detect the common sources? I was looking at the
metadata
target but it only has a
main
compilation and no
test
.
The context here is a gradle plugin that will involve code generation. I want to understand what assumptions I can and can’t make about where to put common sources.
j

josephivie

02/11/2019, 7:11 AM
Close enough, I'd say. Every project I've seen use commonMain and commonTest, and if I saw correctly in my tests, such source sets will always exist, even if unused. Out of curiosity, you interested in sharing what you are building? Sounds interesting
g

GarouDan

02/11/2019, 10:31 AM
Well, as far as I know we will always have a commonMain and a commonTest source set. Reference: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html
These are the default source set names for the production and test sources for the targets configured above. The source sets commonMain and commonTest are included into production and test compilations, respectively, of all targets. Note that the dependencies for common source sets commonMain and commonTest are the common artifacts, and the platform libraries go to the source sets of the specific targets.
Also you can do something like:
js().compilations.main.defaultSourceSet  { /* ... */ }
js().compilations.test.defaultSourceSet { /* ... */ }
I don’t know what about using project.kotlin.sourceSets, but I think it should work.
One other way to access the compilations, is:
kotlin.targets."$target".compilations.main
where I got this from:
task copyFramework {
    def buildType = project.findProperty('kotlin.build.type') ?: 'DEBUG'
    def target = project.findProperty('kotlin.target') ?: 'ios'
    dependsOn kotlin.targets."$target".compilations.main.linkTaskName('FRAMEWORK', buildType)

    doLast {
        def srcFile = kotlin.targets."$target".compilations.main.getBinary('FRAMEWORK', buildType)
        def targetDir = getProperty('configuration.build.dir')
        copy {
            from srcFile.parent
            into targetDir
            include 'app.framework/**'
            include 'app.framework.dSYM'
        }
    }
}
h

h0tk3y

02/11/2019, 12:25 PM
Yes,
commonMain
and
commonTest
source sets are always created by the
kotlin-multiplatform
plugin, you can expect them to be there if that plugin is applied. However, other plugins that create the
kotlin
extension don't create these source sets, so you should check if they are present unless you are targeting MPP only.
The names for these source sets are defined here: https://github.com/JetBrains/kotlin/blob/c4b3580c31a5290089c397663c834dc629b2ae7f/libraries/tools/kotlin-gradle-plugin-api/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinSourceSet.kt#L39-L40
There's currently no other API to access them both. If you feel such an API would be appropriate, please file a feature request.
r

russhwolf

02/11/2019, 2:25 PM
@GarouDan Yes I've been doing things like you describe to detect platform sources in a dynamic way. But I wasn't sure if I should also be detecting common sources dynamically @h0tk3y Thanks, this gives me the confirmation I need. I don't think I need a new API to dynamically detect them for my current use-case, as long as I know that they're always there.
View count: 7