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

    Christian Sousa

    04/03/2020, 9:29 AM
    How do you guys get over the
    unresolved reference: platform
    in a mpp project? It seems that this happens according to the weather or something like that, sometimes it works fine and I can use autocomplete for the
    platform
    but other time it simply doesn’t. I already tried invalidating caches and restart, tried removing some folder that I saw in a random stackoverflow thread, but it still happens.
    a
    • 2
    • 4
  • c

    Christian Sousa

    04/03/2020, 11:40 AM
    Hello guys, I’m trying to get the
    GoogleTagManager
    DataLayer in a kotlin multiplatform project, and I got it working for the Android easily. Problem is with iOS, following their guide I need to use the GoogleTagManager cocoapod: https://developers.google.com/tag-manager/ios/v3/swift I also needed to create a BridgingHeader as their tutorial says. What I did was: Create a BridgingHeader.framework myself, with the following headers that are here: https://github.com/jigish/GoogleTagManager/tree/master/GoogleTagManager/Library plus a BridgingHeader-umbrella.h as follows:
    #ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #else
    #ifndef FOUNDATION_EXPORT
    #if defined(__cplusplus)
    #define FOUNDATION_EXPORT extern "C"
    #else
    #define FOUNDATION_EXPORT extern
    #endif
    #endif
    #endif
    #import "TAGManager.h"
    #import "TAGContainer.h"
    #import "TAGContainerOpener.h"
    #import "TAGDataLayer.h"
    #import "TAGLogger.h"
    Added a module.modulemap like so:
    framework module BridgingHeader {
      export *
      umbrella header "BridgingHeader-umbrella.h"
      header "TAGContainer.h"
      header "TAGContainerOpener.h"
      header "TAGContainerOpener.h"
      header "TAGDataLayer.h"
      header "TAGLogger.h"
      header "TAGManager.h"
    }
    And my BridgingHeader.def is:
    language = Objective-C
    modules = BridgingHeader
    compilerOpts = -framework BridgingHeader
    linkerOpts = -framework BridgingHeader
    But it doesn’t seem right. Anyone had something similar like this that could provide some insight? Also, thanks to @magnumrocha for his help with this issue before 🙂
    👍 1
    k
    • 2
    • 1
  • j

    John O'Reilly

    04/03/2020, 8:53 PM
    Somewhat related to that....has anyone an example of using Ktor on macOS (as part of Multiplatform project)? I can use Ktor 1.3.2 with Coroutines 1.3.5-native-mt on iOS but doesn't work on macOS.
    m
    • 2
    • 4
  • u

    ushort

    04/04/2020, 2:56 AM
    Hello, was wondering how I'd go about creating a multiplatform project that targets android but also jvm for desktop. Basically sharing logic between android and desktop applications. I tried creating new jvm target with different name and came across some variant errors.
    t
    • 2
    • 3
  • j

    judrummer

    04/04/2020, 2:53 PM
    Hi, I have a problem after I upgrade Kotlin multiplatform version from 1.3.61 to 1.3.71. It's work fine in iOS 13.3 but when I try to run in iOS12.0 , It's crash as screenshot below. Anyone met this issue before? I test on Xcode 11.3.1 and 11.4
    b
    • 2
    • 3
  • k

    Kweku

    04/04/2020, 3:25 PM
    How is everyone currently handling dependency Injection? The app I'm working on for Android and IOS use KMP for the domain and data layers then Flutter for the UI. I was thinking of handling DI outside of KMP, for exame using dagger for Android as in native Android I've mages to use Dagger in a way where my domain and data layers have no dependencies on Dagger. The problem is I'm unsure about doing this for Ios having never developed for it before although I've read Needle and Dagger are similar? I've seen Koin( which I've used before) and KodeIn (which I haven't) be mentioned but haven't seen any example usage and theres also the option of doing it myself(Pure DI) Basically I've done a some research but it's the native part that is making me wary as I've seen things about concurrency issues TDLR: I'd like to know if anyone has any experience with DI on KMP
    j
    r
    +3
    • 6
    • 12
  • d

    Damiano Giusti

    04/04/2020, 7:47 PM
    I receive the following error:
    Could not find method npm() for arguments [cheerio] on object of type org.jetbrains.kotlin.gradle.plugin.mpp.DefaultKotlinDependencyHandler.
    I’m using the Groovy DSL
    p
    • 2
    • 2
  • r

    ritesh

    04/05/2020, 10:11 AM
    Hey folks 👋 Can someone point me in the right direction regarding how & where to host my private KMP lib which needs to be consumed in a separate Android project? 🤔 (jitpack?)
    c
    m
    +3
    • 6
    • 9
  • g

    Gunslingor

    04/06/2020, 3:24 AM
    is it possible to make a mutliplatform project with all of the above: js, jvm, android, ios, common?
    s
    • 2
    • 4
  • p

    phldavies

    04/06/2020, 8:55 AM
    Is anyone aware of an eventbus library for KMP, supporting at least JVM (Android) and K/N (iOS)? And is there any directory of KMP libraries where we can go to discover what’s out there?
    a
    j
    • 3
    • 3
  • c

    Christian Sousa

    04/06/2020, 4:00 PM
    Hello guys, is there a way to combine both release and debug
    .framework
    into one single file? So I wouldn’t need to provide both versions, one for simulator and one for devices. I tried using the following script:
    # create folder where we place built frameworks
    mkdir build
    # create folder to store compiled framework for simulator
    mkdir build/simulator
    # copy compiled framework for simulator into our build folder
    cp -r debugFramework/MyLib.framework build/simulator
    # create folder to store compiled framework for simulator
    mkdir build/devices
    # copy compiled framework for simulator into our build folder
    cp -r releaseFramework/MyLib.framework build/devices
    # create folder to store compiled universal framework
    mkdir build/universal
    ####################### Create universal framework #############################
    # copy device framework into universal folder
    cp -r build/devices/MyLib.framework build/universal/
    # create framework binary compatible with simulators and devices, and replace binary in unviersal framework
    lipo -create   build/simulator/MyLib.framework/MyLib   build/devices/MyLib.framework/MyLib   -output build/universal/MyLib.framework/MyLib
    # copy simulator Swift public interface to universal framework
    cp build/simulator/MyLib.framework/Modules/MyLib.swiftmodule/* build/universal/MyLib.framework/Modules/MyLib.swiftmodule
    But it fails with:
    fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: build/simulator/MyLib.framework/MyLib and build/devices/MyLib.framework/MyLib have the same architectures (x86_64) and can't be in the same fat output file
    k
    • 2
    • 8
  • s

    Sean Keane

    04/06/2020, 5:44 PM
    Hi All! Been trying to migrate to 1.4-M1 but have issues when it comes to JsonFeature install.
    Unresolved reference: json
    Unresolved reference: json
    Unresolved reference: JsonFeature
    Unresolved reference: serializer
    Unresolved reference: KotlinxSerializer
    Unresolved reference: JsonFeature
    Unresolved reference: serializer
    Unresolved reference: KotlinxSerializer
    Every time I build I get the above errors. As far as I can see im not missing anything and my IDE doesnt complain. These are the dependacies I have installed.
    const val kotlin = "1.4-M1"
        const val ktor = "1.3.2-1.4-M1-2"
        const val coroutinesCore = "1.3.5-1.4-M1"
        const val serializationCommon = "0.20.0-1.4-M1"
    The network request itself is very simple.
    private val client: HttpClient by lazy {
            return@lazy HttpClient {
                install(JsonFeature) {
                    serializer = KotlinxSerializer()
                }
            }
        }
    
        override fun getVersion(onSuccess: (Version) -> Unit, onError: (KarhooError) -> Unit) {
            coroutineScope.launch {
                val resp: Version = client.get(VERSION_METHOD)
                onSuccess.invoke(resp)
            }
        }
    The imports are added with no issues and I can see the build libs. Just very lost as to why it can't locate the files during a build?
    • 1
    • 2
  • g

    Gunslingor

    04/06/2020, 8:33 PM
    I'm in aw of how powerful it could be... but its confusing. Like the Kotlin Multiplatform plugin creates this template... why has it proven so difficult to add android and iOS as source sets? Its as if Multiplatform plugin doesn't have them or something.
    r
    s
    • 3
    • 70
  • c

    coletz

    04/06/2020, 9:54 PM
    Hi guys, anyone know if it's possible to have on a kmp something like BuildConfig on android? I'd like specify some constants in the common build.gradle(.kts) and access them in the common code (like staging/prod/test endpoints and so on, as I was used to android flavors/build config etc)
    r
    • 2
    • 2
  • o

    Olenyov Kirill

    04/06/2020, 9:59 PM
    Hi everyone, does anybody had a problem with delay() on ios platform? I have a simple loop: while(true) { println(“log1”) delay(1000) println(“log2") } launched on GlobalScope. On Android it works fine but on ios it doesn’t. Like delay has infinite timeout…
    s
    l
    k
    • 4
    • 27
  • g

    Gunslingor

    04/07/2020, 5:05 PM
    Anyone know what these messages mean, they are from Idea correct and not gradle correct? It sounds like I could still use gradle and the IDE gradle plugin but that the IDEA can't communicate with gradle? I see these messages too often
    • 1
    • 1
  • j

    Jess Brent

    04/07/2020, 7:44 PM
    not sure if this is the right place, i’m a little baffled trying to make this work and i can’t seem to find anything on google to answer my questions. function:
    inline fun <reified T> withResult(
        method: Result<T>,
        onFailure: (errors: List<Throwable>) -> Unit
    ): T {
            @Suppress("IMPLICIT_CAST_TO_ANY")
            val methodResult = when (method) {
                is Result.Success -> { method.t }
                is Result.Failure -> { onFailure.invoke(method.errors) }
            }
            return methodResult as T
    }
    usage:
    val r = withResult(method) { return Result.Failure(it) }
    i can get this function to work on jvm, however it does not work on js. it results in a
    ClassCastException
    the transpiled js appears to show that instead of invoking
    onFailure
    it is only assigned to
    methodResult
    . also, this is a custom sealed class
    Result
    not
    kotlin.Result
    i’m hoping i’m missing something obvious here. 😅
    • 1
    • 1
  • g

    Gunslingor

    04/08/2020, 6:24 AM
    Trying to make a js/jvm/android/ios multiplatform project, haven't started iOS yet... I had js/jvm working pretty well and understood most of it, I have android sort of working now but holly molly there are 50 milltion tasks now, half of them don't seem to work... how the heck do you build and test this stuff.
    a
    b
    • 3
    • 13
  • g

    Gunslingor

    04/08/2020, 8:57 AM
    Yeah... I'm about to give up on this whole dam platform. I'm done for the night.
    k
    r
    k
    • 4
    • 26
  • e

    edenman

    04/08/2020, 9:51 PM
    I’ve got a kotlin multiplatform module and AS is having trouble resolving a bunch of the symbols
    d
    r
    l
    • 4
    • 12
  • n

    Nikolay Kasyanov

    04/09/2020, 6:53 AM
    Hey folks, is anyone else seeing this? While upgrading our project to 1.3.71, I also switched to the recommended syntax of defining iOS source sets, replacing this:
    iosX64Main { ...dependencies... }
    iosArm64Main {
        dependsOn iosX64Main
    }
    with this:
    ios {
        iosArm64Main.dependsOn it
        iosX64Main.dependsOn it
    
        ...dependencies...
    }
    moving iOS-only source files from
    iosX64Main
    to
    ios
    folder accordingly. Now all imports starting with
    platform.
    are highlighted red in the IDE all the time, builds fine though. Is this a known issue?
    a
    o
    • 3
    • 30
  • i

    ivano

    04/09/2020, 7:19 AM
    OT dart is so ugly there is a way i can use Kotlin for Flutter?
    🇳🇴 3
    m
    o
    k
    • 4
    • 5
  • k

    Kevin S

    04/09/2020, 1:25 PM
    Does anyone know if 1.3.7 supports multiple static K/N frameworks? The release notes mention support for more than one dynamic framework, which I’ve tested and works, but I tried with static frameworks and am getting the
    duplicate symbols for architecture
    error since there are two versions of things like
    Kotlin.Any
    k
    s
    • 3
    • 11
  • c

    Christian Sousa

    04/09/2020, 1:57 PM
    Hello guys, I’m trying to add something to my
    build.gradle.kts
    like:
    android {
     ...
     ...
     compileOptions {
       kotlinOptions {
       ...
       }
     }
    }
    But I get unresolved reference to kotlinOptions.. anyone can give a little help? Thanks!
    s
    • 2
    • 1
  • o

    Olenyov Kirill

    04/09/2020, 2:20 PM
    Hi, how can I share actual/expect code for iOS and tvOS. For example, “expect” CoroutineDispatcher implementation is the same for iOS and tvOS but I need to copy/paste it in each ios/tvos source sets..
    a
    • 2
    • 2
  • s

    saket

    04/09/2020, 7:38 PM
    I’d like to create a macOS app, and was wondering if it’s a good idea to to write it using UiKit instead and then port to macOS. Dev guides for App Kit are awfully low.
    j
    s
    k
    • 4
    • 6
  • c

    curioustechizen

    04/10/2020, 12:56 PM
    How do I invoke the
    syncFramework
    gradle task manually? Where do all the parameters for it come from? (
    $HEADER_SEARCH_PATHS
    ,
    $OTHER_CFLAGS
    etc)? My objective is to build the framework manually and publish it to a remote cocoapods repo.
    a
    • 2
    • 8
  • t

    taso

    04/10/2020, 1:59 PM
    I'm looking at the multiplatform sample on SqlDelight. It only has the common code in the common lib. Platform specific (Android/iOS) drivers are added in top level app module. My question is that how would this work on a Multiplatform library. Let's say we have a library where the persistence is an implementation detail. Is it possible to keep it all in the "common" module and all users will automagically get the correct version?
    j
    a
    +2
    • 5
    • 45
  • g

    Gunslingor

    04/10/2020, 7:21 PM
    Has anyone made a multiplatform app that utilizes flutter? Been doing my front ends in flutter last few days and I'm liking it, need to combine it with my ktor server stuff for the same product so I can have unified codebase, git, maybe common kotlin lib later, etc. Wondering if there is a recommended way to do that.
    s
    k
    s
    • 4
    • 31
  • c

    curioustechizen

    04/11/2020, 10:30 AM
    Are there any examples of running multiplatform tests on iOS? We have our KMP code covered by tests but they're JUnit tests. Currently we only run them on the development host. I want to also run them on iOS but I don't know how. What would the entry point be? Would I need to convert from JUnit to something else?
    e
    b
    • 3
    • 4
Powered by Linen
Title
c

curioustechizen

04/11/2020, 10:30 AM
Are there any examples of running multiplatform tests on iOS? We have our KMP code covered by tests but they're JUnit tests. Currently we only run them on the development host. I want to also run them on iOS but I don't know how. What would the entry point be? Would I need to convert from JUnit to something else?
e

eskatos

04/11/2020, 10:48 AM
Yes, you’d need to use
kotlin-test
. Then with >= 1.3.70 you’ll be able to run them in an ios simulator out of the box.
c

curioustechizen

04/11/2020, 10:49 AM
Awesome. I'll look into it. Thanks!
e

eskatos

04/11/2020, 10:49 AM

https://d3nmt5vlzunoa1.cloudfront.net/kotlin/files/2021/02/js-native-test.gif▾

❤️ 3
b

basher

04/11/2020, 2:30 PM
iosX64Test is the gradle task. It runs them in an iOS simulator.
View count: 6