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

    Hyun

    07/03/2020, 12:18 AM
    Hi, I have a question when I try to access ios library in builtin some libraries are missing like below.
    SwiftUI.Image
    platform.CoreGraphics.CGImage
    is there any way to access them?
    a
    • 2
    • 4
  • m

    Mgj

    07/03/2020, 8:06 AM
    It seems like you cannot use kotlinx.coroutines.flow.MutableStateFlow in common code? Only platform-specific code?
    g
    e
    l
    • 4
    • 18
  • t

    Theo

    07/04/2020, 8:35 AM
    does anyone have experience with Realm? I know there is an open ticket on realm-cocoa about supporting multiplatform projects somehow, how difficult would it be to write wrappers around realm-java and realm-cocoa for a kotlin multiplatform project, I'm stuck on how I would approach creating the Realm models... (currently I'm just handling the persistence outside of KMP, maybe this if fine for now until it's officially supported upstream)
    s
    m
    • 3
    • 6
  • z

    zsperske

    07/04/2020, 9:04 PM
    This may be too broad a question (and of course I understand KMP is still in development) so I apologize up front but has anyone else noticed that debugging Android apps in a KMP project with IntelliJ sucks? Debugger often doesn't gather field values making it near useless. I have to resort to starting android studio nearly every time
    a
    • 2
    • 1
  • s

    Sebastien Leclerc Lavallee

    07/05/2020, 4:31 AM
    Hi! I’m trying to create an archive of my iOS project to upload to AppStore but I get this error:
    ld: bitcode bundle could not be generated because '/shared42/build/cocoapods/framework/shared42.framework/shared42(result.o)' was built without full bitcode. All object files and libraries for bitcode must be generated from Xcode Archive or Install build file '/shared42/build/cocoapods/framework/shared42.framework/shared42' for architecture arm64
    I was using the
    packForXcode
    task way before (with embedding the .framework directly, working fine) but now I moved to cocoapods way and I get this error. How do we enable bitcode ? Thanks!
    s
    • 2
    • 2
  • j

    janvladimirmostert

    07/05/2020, 9:24 AM
    which repository do i need to make use of coroutines in 1.4 M2?
    sourceSets {
    		val commonMain by getting {
    			dependencies {
    				implementation(kotlin("stdlib-common"))
    
    				val coroutinesVersion = "1.3.7-1.4-M2"
    				api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
    			}
    		}
    > Could not find org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.7-1.4-M2.
         Searched in the following locations:
           - <https://jcenter.bintray.com/org/jetbrains/kotlinx/kotlinx-coroutines-core-common/1.3.7-1.4-M2/kotlinx-coroutines-core-common-1.3.7-1.4-M2.pom>
           - <https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-coroutines-core-common/1.3.7-1.4-M2/kotlinx-coroutines-core-common-1.3.7-1.4-M2.pom>
           - <https://dl.bintray.com/kotlin/kotlin-eap/org/jetbrains/kotlinx/kotlinx-coroutines-core-common/1.3.7-1.4-M2/kotlinx-coroutines-core-common-1.3.7-1.4-M2.pom>
           - <https://kotlin.bintray.com/kotlinx/org/jetbrains/kotlinx/kotlinx-coroutines-core-common/1.3.7-1.4-M2/kotlinx-coroutines-core-common-1.3.7-1.4-M2.pom>
         Required by:
    r
    i
    • 3
    • 9
  • z

    zsperske

    07/05/2020, 6:55 PM
    Does anyone know what gradle command I should be running to run tests from "commonTest"? I'm using
    Kotlin.test.Test
    annotations and when I try to right click and run from Intellij it generates this test command which looks wrong
    cleanIosTest iosTest --tests "tests.MyTest.test
    , I've tried changing the command to just
    test --tests "tests.MyTest.test
    to no avail
    a
    • 2
    • 6
  • s

    saket

    07/05/2020, 10:35 PM
    Breakpoints seem to have stopped working on IntelliJ when running my code on Android. Has anyone else experienced this lately?
    r
    • 2
    • 3
  • f

    Friedger

    07/06/2020, 1:54 PM
    Building my shared folder (./gradlew shared:build) hangs (gradle does not progress anymore) when I build on mac. Gradle is doing iosTest
    • 1
    • 2
  • s

    saket

    07/06/2020, 5:18 PM
    can you fork assert4k, bump kotlin and push it to maven under your name?
    d
    f
    • 3
    • 5
  • s

    saket

    07/06/2020, 8:07 PM
    Is anyone working with files in their multiplatform project?
    b
    c
    d
    • 4
    • 16
  • m

    Mgj

    07/07/2020, 10:53 AM
    Is it possible to use Android databinding with kotlin multiplatform? I'm able to enable databinding in the module
    build.gradle
    :
    dataBinding {
            enabled = true
        }
    But since i have custom binding adapters i also need
    kotlin-kapt
    plugin. As soon as i add it i get a build error:
    C:\x\app\build\generated\source\kapt\release\androidx\databinding\library\baseAdapters\BR.java:3: error: package javax.annotation does not exist
    import javax.annotation.Generated;
    
    
    C:\x\app\build\generated\source\kapt\release\y\databinding\FragmentLoginBindingImpl.java:8: error: package javax.annotation does not exist
    @javax.annotation.Generated("Android Data Binding")
    Perhaps i need to enable the
    kotlin-kapt
    plugin only for the android target (since it seems to have a dependency on javax.annotation) - How can i do this?
    • 1
    • 2
  • m

    Mgj

    07/07/2020, 1:44 PM
    Anyone managed to use android databinding with binding to
    StateFlow
    or
    MutableStateFlow
    properties? I've created custom binding adapters before, but i cannot get it to work properly with StateFlows
    l
    o
    • 3
    • 12
  • b

    bod

    07/08/2020, 9:10 AM
    Hello, World! I have a very simple and small Kotlin/JVM project that uses a SQLite database, currently via JDBC. I'd like to "port" it to full Native (targeting MacOS only for now would be enough). I was wondering if anybody had any general advices and/or pointers about where to start 🙂 Thanks!
    b
    • 2
    • 5
  • a

    albertosh

    07/08/2020, 3:22 PM
    Hi Anyone tried to typealias an `expect`ed class? Looks like I can do it for the JVM but not for JS. The aim is to provide a “platform native” output for some functions so they can be used from Java/Js My common code
    expect class Wrapper<T: Any?>
    Working Kotlin for JVM code
    actual typealias Wrapper<T> = CompletableFuture<T>
    Not working Kotlin for JS code
    actual typealias Wrapper<T> = Promise<T>
    Compiler claims that
    Aliased class should not have type parameters with declaration-site variance
    Any clue?
    b
    r
    • 3
    • 4
  • j

    Jim

    07/08/2020, 4:39 PM
    Hey there new here! I’ve been working on a project I’m planning to open source but I want to use a multiplatform build so the library is consumable from: kotlin, java, and js (typescript). common -> top level functions and extensions on abstract classes let’s say jvm -> a class or two that use that abstract class js -> a class or two that use that abstract class Before I split the code up this way, do I need to re-export all of the top level functions in common to the other two targets or do they come for free?
    k
    • 2
    • 2
  • s

    Sean Najera

    07/08/2020, 10:25 PM
    I just created a kotlin multiplatform library for android, ios and Javascript which uses the Ktor client for all networking. These are my dependencies for the javascript library
    // MPP - JS & common dependencies
    
        sourceSets["commonMain"].dependencies {
            implementation(kotlin("stdlib-common", Versions.KOTLIN))
            implementation(Deps.Ktor.COMMON_CORE)
            implementation(Deps.Ktor.COMMON_JSON)
            implementation(Deps.Coroutines.COMMON)
            implementation(Deps.MP_SETTINGS)
            implementation(Deps.Ktor.COMMON_SERIALIZER)
            implementation(Deps.Serialization.COMMON)
            implementation(Deps.Stately.COMMON)
            implementation(Deps.Stately.CONCURRENCY)
        }    
    
        sourceSets["jsMain"].dependencies {
            implementation((kotlin("stdlib-js", Versions.KOTLIN)))
            implementation(Deps.Ktor.JS_CORE)
            implementation(Deps.Ktor.JS_JSON)
            implementation(Deps.Coroutines.JS)
            implementation(Deps.Ktor.JS_SERIALIZER)
            implementation(Deps.Serialization.JS)
        }
    My goal is to write the repository layer as a library for the three platforms which can use it to request proprietary data, similar to Firebase Realtime database. But when I import the JS library into the Jetbrains starter React app my javascript binary is 27MiB for dev and 1MiB for prod distributions. Should I expect ktor & coroutines JS libraries to be that heavy for a JS library? Or am I doing something wrong?
    r
    j
    • 3
    • 10
  • m

    Mgj

    07/09/2020, 1:18 PM
    For iOS, anyone know a resource for how to define CPointers? Im trying to do something like this:
    val view: UITextField
    view.addTarget(target = view, action = ::onTextChanged, forControlEvents = UIControlEventEditingChanged)
    But its not allowed because Required: COpaguePointer? Found: KFunction0 Apparently theres an
    toCPointer()
    function? I cant seem to import it, so im unsure how its to be used
    k
    • 2
    • 12
  • m

    Maurice Jouvet

    07/09/2020, 1:51 PM
    Hi, I have started a new project with KMP. I already tested one successfully, but the architecture wasn't good enought for me. Concretly, I would like to call that easily on iOS:
    // UseCase
    suspend fun run(params: LoginModel): Token = authenticationRepo.auth(params)
    It's easy on Android but on iOS I'm struggling.. I used to create a Protocol and a view that is the copy of the android version, but I have to work with event and callbacks. Is there an "easy way" to do the same android call that on iOS :
    @UiThread
    fun authenticateAsync(loginModel: LoginModel): Deferred<Token> {
    return viewModelScope.async {
    authenticationTokenUseCase.run(loginModel)
    }
    }
    s
    b
    a
    • 4
    • 13
  • c

    chadmorrow

    07/09/2020, 8:11 PM
    Ok this has been quite painful and I'm floundering and could use some help. I have a multiplatform project and i want to use the shadowjar plugin to package up a jvm jar for deployment to aws. I had this working no sweat when using just the jvm kotlin plugin but using the multiplatform plugin makes the shadowjar task disappear from gradle and I can't figure out how to set it up right. There's half a dozen answers on stack overflow that purport to have an answer and none of them seem to even use valid syntax in the build.gradle.kts file anymore. Is there not an easier way to get an uberjar in a multiplatform project?
    • 1
    • 2
  • a

    andymin

    07/09/2020, 8:14 PM
    Hello, I have a project setup as such in which jvm1 and jvm2 and different targets:
    src
    * commonMain
    * commonTest
    * jvm1Main
    * jvm2Main
    * jvm2Test
    I want it so that running
    check
    or
    build
    would run
    jvm2Test
    and
    commonTest
    so I setup my `build.gradle`:
    kotlin {
        jvm('jvm1')
        jvm('jvm2')
    
        sourceSets {
            commonMain { dependencies { ... } }
    
            commonTest {
                dependencies {
                    implementation kotlin('test-annotations-common')
                }
            }
    
            jvm1Main {
                dependsOn commonMain
    
                dependencies { ... }
            }
    
            jvm2Main {
                dependsOn commonMain
    
                dependencies { ... }
            }
    
            jvm2Test {
                dependsOn commonTest
    
                dependencies {
                    implementation kotlin('test')
                    implementation kotlin('test-junit')
                }
            }
        }
    }
    However, running
    ./gradlew build
    tries to compile
    commonTest
    through both
    jvm1Test
    and
    jvm2Test
    , and fails since
    jvm1Test
    doesn't have any test dependencies. Is there a way to disable
    jvm1Test
    or decouple it from
    commonTest
    ?
    e
    • 2
    • 4
  • k

    Kroppeb

    07/10/2020, 8:48 AM
    I'm getting these kind of errors:
    Cannot access built-in declaration '...'. Ensure that you have a dependency on the Kotlin standard library
    I'm confused as to why it can't find the stdlib?
    Untitled
    👍 1
    r
    v
    • 3
    • 5
  • r

    Rita Curado

    07/10/2020, 9:22 AM
    Hi everyone! Could someone tell me if it is possible to access properties from
    gradle.properties
    in common code? If not, how can I set an environment variable and read it on common code? Thanks in advance
    k
    a
    s
    • 4
    • 7
  • b

    bod

    07/11/2020, 1:16 PM
    Hello, World! I'm having trouble finding the correct syntax to declare an
    expect
    class and reflecting the constructors of the
    actual
    one. Here's what I'm trying to do: common:
    expect class File(path: String) {
        constructor(path: File, name: String)
    
        fun isDirectory(): Boolean
    }
    jvm:
    actual class File actual constructor(path: String): java.io.File(path) {
        actual constructor(path: File, name: String)
    }
    This results in
    Primary constructor call expected
    s
    k
    d
    • 4
    • 14
  • v

    vashisthg

    07/11/2020, 1:42 PM
    Any idea about this error
    Could not determine the dependencies of task ':[projectname]:compileDebugAidl'.
    > Could not resolve all task dependencies for configuration ':[projectname]:debugCompileClasspath'.
       > Could not resolve project :[shared-library-name].
         Required by:
             project :[projectname]
    Cannot choose between the following variants of project :[shared-library-name]:
              - androidApiElements
              - androidCompile
              - androidCompileOnly
              - androidDefault
              - androidRuntime
              - androidRuntimeElements
              - androidTestCompile
              - androidTestRuntime
              - iosRuntimeOnly
              - jvmApiElements
              - jvmCompile
              - jvmCompileOnly
              - jvmDefault
              - jvmRuntime
              - jvmRuntimeElements
              - jvmTestCompile
              - jvmTestRuntime
    a
    • 2
    • 5
  • b

    bod

    07/11/2020, 6:18 PM
    me again... any ideas why
    import kotlinx.coroutines.Job
    is unknown in my common code, even when I have this dependency:
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$versionsCoroutine")
    ?
    m
    m
    • 3
    • 3
  • r

    Renann

    07/11/2020, 11:44 PM
    Hello! I'm trying to do the following: 1. Create a kotlin lib 2. Generate the
    .d.ts
    files (I don't use the generated javascript code!) 3. Create a typescript script which uses the
    .d.ts
    4. Compile to javascript 5. Run in the GraalVM The end result I'm looking for like a binding for my kotlin classes to be called from typescript. I'm using latest kotlin version 1.4-M3. Disclaimer I'm not expert in typescript (nor kotlin), but I could do everything, however: 1. The generated typescript definition file doesn't
    export
    module, so I cannot import in my typescript script 2. I added the export keyword to fix it 3. Now I can import the definition and use it, however in order to execute in GraaVM what I need is to import java types from javascript by using the
    Java.type
    call instead of
    require
    Now I would like to know if there's a way to modify the kotlin generator so that I could achieve transpilation from such imported types to javascript and be callable by GraalVM out of the box. Some guidance on this topic would nice and I believe at least the
    export
    of the module should be part of the core kotlin generator.
    r
    b
    • 3
    • 16
  • g

    gumil

    07/12/2020, 9:26 PM
    hello i have a multiplatform module that has coroutines as a dependency, when it tries to do
    linkDebugTestIos
    i get this error
    e: Could not find "atomicfu-cinterop-interop"
    I have added this as a dependency to the native source set
    "org.jetbrains.kotlinx:atomicfu-native:0.14.3"
    but it sill has the same error. Can anyone help me figure this out?
    e
    • 2
    • 7
  • j

    Jeff

    07/13/2020, 7:46 AM
    Hello, My client doesn't print logs when I make requests through my Android app. Any help would be appreciated. I only get to see:
    I/System.out: [OkHttp] sendRequest>>
    The code is as follows:
    private val client by lazy {
            HttpClient {
                install(JsonFeature) {
                    serializer = KotlinxSerializer(
                        Json(
                            JsonConfiguration(
                                isLenient = true,
                                ignoreUnknownKeys = true
                            )
                        )
                    )
                }
                install(Logging) {
                    logger = Logger.DEFAULT
                    level = LogLevel.ALL
                }
            }
        }
    :stackoverflow: 1
    s
    k
    r
    • 4
    • 9
  • w

    willyrs

    07/13/2020, 10:11 AM
    how can I have all ios targets to have the same kotlin files? I have:
    iosX64("ios")
    iosArm32("iosArm32")
    iosArm64("iosArm64")
    and I’m trying to have all 3 share the same iosMain folder:
    sourceSets["iosArm32Main"].dependsOn(sourceSets["iosMain"])
    but it fails with:
    A problem occurred configuring project ':shared'.
    Collection has more than one element.
    k
    • 2
    • 13
Powered by Linen
Title
w

willyrs

07/13/2020, 10:11 AM
how can I have all ios targets to have the same kotlin files? I have:
iosX64("ios")
iosArm32("iosArm32")
iosArm64("iosArm64")
and I’m trying to have all 3 share the same iosMain folder:
sourceSets["iosArm32Main"].dependsOn(sourceSets["iosMain"])
but it fails with:
A problem occurred configuring project ':shared'.
Collection has more than one element.
k

Kris Wong

07/13/2020, 1:39 PM
compilations["main"].defaultSourceSet {
            dependsOn(sourceSets["iosMain"])
        }
w

willyrs

07/13/2020, 1:39 PM
thanks! I’ll try this
k

Kris Wong

07/13/2020, 1:40 PM
goes in your target scope
w

willyrs

07/13/2020, 1:42 PM
ok, ty
i thought this was a problem with the dependencies, but I have that error just by adding another ios abi in the kotlin { } part, like
kotlin {
    iosArm64("iosarm")
    iosX64("ios")
}
this shows: A problem occurred configuring project ‘:shared’.
Collection has more than one element.
k

Kris Wong

07/13/2020, 4:04 PM
the code snippet you have pasted will not cause that. I have a number of projects setup like this.
w

willyrs

07/13/2020, 4:06 PM
uhm, that’s strange, if I comment one of them it works tho
this is the complete gradle file
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
    kotlin("multiplatform")
    id("co.touchlab.native.cocoapods")
    id("kotlinx-serialization")
    id("com.android.library")
}

android {
    compileSdkVersion(29)
    defaultConfig {
        minSdkVersion(Versions.min_sdk)
        targetSdkVersion(Versions.target_sdk)
        versionCode = 1
        versionName = "1.0"
        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
    }
}

kotlin {
    android()
    jvm()
    js {
        browser {
            useCommonJs()
        }
    }
    //iosArm64("iosarm")
    iosX64("ios")

    targets.getByName<KotlinNativeTarget>("ios").compilations["main"].kotlinOptions.freeCompilerArgs +=
        listOf("-Xobjc-generics", "-Xg0")

    version = "1.1"

    sourceSets {
        all {
            languageSettings.apply {
                useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi")
            }
        }
    }

    sourceSets["commonMain"].dependencies {
        implementation(kotlin("stdlib-common", Versions.kotlin))
        implementation(Deps.Ktor.commonCore)
        implementation(Deps.Ktor.commonJson)
        implementation(Deps.Ktor.commonLogging)
        implementation(Deps.Coroutines.common)
        implementation(Deps.stately)
        implementation(Deps.multiplatformSettings)
        implementation(Deps.koinCore)
        implementation(Deps.Ktor.commonSerialization)
        implementation(Deps.Redux.core)
        api(Deps.kermit)
    }

    sourceSets["commonTest"].dependencies {
        implementation(Deps.multiplatformSettingsTest)
        implementation(Deps.KotlinTest.common)
        implementation(Deps.KotlinTest.annotations)
        implementation(Deps.koinTest)
        // Karmok is an experimental library which helps with mocking interfaces
        implementation(Deps.karmok)
        implementation(Deps.Ktor.mock)
    }

    sourceSets["androidMain"].dependencies {
        implementation(kotlin("stdlib", Versions.kotlin))
        implementation(Deps.Ktor.jvmCore)
        implementation(Deps.Ktor.jvmJson)
        implementation(Deps.Ktor.jvmLogging)
        implementation(Deps.Coroutines.jdk)
        implementation(Deps.Coroutines.android)
        implementation(Deps.Ktor.androidSerialization)
        implementation(Deps.Ktor.androidCore)
    }

    sourceSets["jvmMain"].dependencies {
        implementation(kotlin("stdlib", Versions.kotlin))
        implementation(Deps.kermitJvm)
        implementation(Deps.Ktor.jvmCore)
        implementation(Deps.Ktor.jvmJson)
        implementation(Deps.Ktor.jvmLogging)
        implementation(Deps.Coroutines.jdk)
        implementation(Deps.Ktor.androidSerialization)
        implementation(Deps.Ktor.androidCore)
    }

    sourceSets["androidTest"].dependencies {
        implementation(Deps.KotlinTest.jvm)
        implementation(Deps.KotlinTest.junit)
        implementation(Deps.AndroidXTest.core)
        implementation(Deps.AndroidXTest.junit)
        implementation(Deps.AndroidXTest.runner)
        implementation(Deps.AndroidXTest.rules)
        implementation(Deps.Coroutines.test)
        implementation(Deps.Ktor.jvmMock)
        implementation(Deps.RoboEletric.droid)
    }

    sourceSets["iosMain"].dependencies {
        implementation(Deps.Ktor.ios)
        implementation(Deps.Ktor.iosCore)
        implementation(Deps.Ktor.iosJson)
        implementation(Deps.Ktor.iosLogging)
        implementation(Deps.Coroutines.native) {
            version {
                strictly("1.3.5-native-mt")
            }
        }
        implementation(Deps.Ktor.iosSerialization)
        implementation(Deps.koinCore)
    }

    sourceSets["jsMain"].dependencies {
        implementation(Deps.Ktor.js)
        implementation(Deps.Ktor.jsCore)
        implementation(Deps.Ktor.jsJson)
        implementation(Deps.Ktor.jsLogging)
        implementation(Deps.Ktor.jsSerialization)
        implementation(Deps.Coroutines.js)
        implementation(Deps.koinCoreJS)
        api(npm("text-encoding"))
        api(npm("bufferutil"))
        api(npm("utf-8-validate"))
        api(npm("abort-controller"))
        api(npm("fs"))
        implementation(npm("styled-components"))
        implementation(npm("inline-style-prefixer"))
        implementation(npm("react-router-dom", "5.1.2"))
        implementation(kotlin("stdlib-js"))
        implementation(npm("react", "16.13.0"))
        implementation(npm("react-is", "16.13.0"))
        implementation(npm("react-dom", "16.13.0"))

        // version 94 is the last one that works (108 and 109 are bugged)
        implementation("org.jetbrains:kotlin-react:16.13.0-pre.94-kotlin-1.3.70")
        implementation("org.jetbrains:kotlin-react-dom:16.13.0-pre.94-kotlin-1.3.70")
        implementation("org.jetbrains:kotlin-styled:1.0.0-pre.94-kotlin-1.3.70")
        implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.5")
        // implementation("org.jetbrains:kotlin-react-router-dom:5.1.2-pre.107-kotlin-1.3.72")
    }

    task("fullBuild") {
        dependsOn("build")
        doLast {
            exec {
                commandLine = "rm -rf ios/shared.framework".split(" ")
            }
            exec {
                commandLine = "mv -f build/bin/ios/releaseFramework/shared.framework ../ios/shared.framework".split(" ")
            }
        }
    }
}
it works!
I’ve removed the cocoapods plugin
it was him
ty for your help
🍻 1
View count: 10