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

    Guilherme Delgado

    03/30/2021, 11:12 PM
    Hello guys! I followed @John O'Reilly MortyComposeKMM regarding multiplatform-paging and it worked fine for android() and _ios(). But n_ow that i’ve added jvm() (wanna try server) I’m facing this problem: Could not resolve all files for configuration ’:shared:jvmCompileClasspath which basically happens because there’s no jvm() dependency from this lib. Can I somehow exclude this dependency (in commonMain) for jvm or the author must provide compatibility? Anyone facing similar problems? Thanks for your time!
    b
    z
    • 3
    • 8
  • c

    Charles Prado

    03/30/2021, 11:38 PM
    Hello everyone. I'm trying to run the iOS project of my KMM project using CocoaPods. But I always get an error when Xcode tries to run this script
    set -ev
                    REPO_ROOT="$PODS_TARGET_SRCROOT"
                    "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" :shared:syncFramework \
                        -Pkotlin.native.cocoapods.target=$KOTLIN_TARGET \
                        -Pkotlin.native.cocoapods.configuration=$CONFIGURATION \
                        -Pkotlin.native.cocoapods.cflags="$OTHER_CFLAGS" \
                        -Pkotlin.native.cocoapods.paths.headers="$HEADER_SEARCH_PATHS" \
                        -Pkotlin.native.cocoapods.paths.frameworks="$FRAMEWORK_SEARCH_PATHS"
    The error doesn't say so much, only that:
    Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure
    I tried then to run
    ./gradlew -p . :shared:syncFramework
    directly from the terminal and it says that
    Task 'syncFramework' not found in project ':shared'.
    Any ideas how can I solve that?
    • 1
    • 1
  • d

    deviant

    03/31/2021, 12:49 PM
    hi guys! how you manage build flavors/variants in KMM projects? particularly multi dimensional flavors e.g. "staging/debug", "free/enterprise" etc
    t
    e
    • 3
    • 4
  • p

    Pedro Motta

    03/31/2021, 5:06 PM
    Hi guys, Is there any multiplatform library that generates a license list? I'm currently using License Tools for Android and LicensePlist for iOS. The problem is that neither of these libraries generates the license for the multiplatform libraries. Thanks in advance
    k
    • 2
    • 2
  • t

    Thomas Flad

    04/01/2021, 9:11 AM
    Hi everyone! I’m wondering how you currently handling the issue with custom configurations for different environments on iOS: https://youtrack.jetbrains.com/issue/KT-42023 I’m not happy with the solution to prevent the generation of the podspec file and add a workaround there. Is there another way around this?
    ➕ 2
    a
    • 2
    • 2
  • a

    archana 0623

    04/02/2021, 11:38 AM
    Hello, I have recently been checking code sharing in KMM and have a question like how to know when to use expect and actual fun in common module KMM and when not to use it, like with some example usecase
    s
    j
    • 3
    • 5
  • l

    Lena Brusilovski

    04/03/2021, 6:30 AM
    anyone know why cinterop does not have extension methods written by apple ? it has the original class, but the original class has some more stuff written in extensions, and that is for some reason missing
    s
    • 2
    • 1
  • s

    Shakil Karim

    04/03/2021, 9:36 AM
    Is possible to share multipart API request between IOS and Android, Is there any example of it somewhere ?
    b
    • 2
    • 4
  • h

    Hossein Amini

    04/03/2021, 12:55 PM
    Hello By adding an iOS library to the Pod it says: - Use the
    $(inherited)
    flag, or - Remove the build settings from the target. Also I can’t import the module to my project. It only happens when I create a KMM project, I mean by creating a new project in Xcode, everything is ok. How can I fix it? Thanks a lot
    s
    • 2
    • 1
  • m

    Michal Klimczak

    04/03/2021, 4:57 PM
    Tl;DR how to write a file (zip downloaded from network) on ios? okio files api seems to be just around the corner, but in the meantime I need to transfer bytes from
    ktor
    ByteReadChannel
    to ios
    NSOutputStream
    (I think) and I don't have an idea how to mix these apis. I'm also gonna need to then unzip it and move the files and dirs from the zip package to the local storage, but this is probably not really feasible in common code before okio files api, right? kotlinx-io seems to be dead.
    s
    j
    • 3
    • 10
  • r

    rnentjes

    04/04/2021, 1:04 PM
    Hi, anyone else have the problem with kotlin multi platform project that intellij asks for the android SDK on gradle refresh even though you don't have any android targets defined?
    s
    • 2
    • 2
  • m

    marzelwidmer

    04/05/2021, 2:12 PM
    Hello I was just trining the following tutorial … https://kotlinlang.org/docs/multiplatform-library.html#create-a-project I was searching for a setup to create Shared Lib for
    ios
    and
    android
    and also
    jvm
    is there maybe a nice other tutorial to follow along 😞 this one I stumble with the Platform specific stuff.. I was trining to put the
    Platforms
    specific code from the
    KMM Templated Sample
    `
    import platform.UIKit.UIDevice
    resp.
    actual val platform: String = "Android ${android.os.Build.VERSION.SDK_INT}"
    I am not really the
    gradle guru
    😉
    b
    • 2
    • 8
  • h

    Halil Ozercan

    04/05/2021, 3:27 PM
    Coming back to multiplatform after 4 months, still having this issue on MacOS. No update on the issue, no new entry in google search results. Does anyone have any idea?
    l
    • 2
    • 1
  • v

    Vitor Prado

    04/05/2021, 4:05 PM
    Is there a way to use some
    env
    values with multiplatform? I’ll try to describe my problem: My
    api
    needs to receive some headers based on application:
    platform, version, language.
    This info is platform-client dependent. How can I achieve it?
    z
    b
    +2
    • 5
    • 22
  • d

    Daniele B

    04/05/2021, 9:45 PM
    Question about SqlDelight: I would like to place the database schema somewhere inside the “*commonMain/kotlin*” folder, rather than the “*commonMain/sqldelight*” folder. But I can’t find the way. Has anyone managed to do it?
    b
    c
    • 3
    • 5
  • s

    Samuel Michael

    04/06/2021, 3:33 AM
    Hey, don't see option for creating new KMM module anymore, tried rolling back and checked out a few different versions, no luck, anyone else experience this?
    • 1
    • 1
  • d

    Daniele B

    04/06/2021, 12:59 PM
    What is the best way to solve this IDE error with the iOS SqlDelight driver?
    k
    k
    • 3
    • 7
  • r

    rsktash

    04/06/2021, 6:31 PM
    What should I do?
    b
    k
    h
    • 4
    • 5
  • f

    felislynx

    04/07/2021, 6:58 AM
    Hi, i want to add new module to project which will be multiplatform shared module. Inside it i want to add dependency on another project. In groovy format it was like:
    include ':OtherProject'
    project(':OtherProject').projectDir = new File('../other_project/module')
    How to achieve that in KTS format?
    c
    k
    • 3
    • 10
  • k

    Kilian Steenman

    04/07/2021, 9:27 AM
    Hi, we have a shared kotlin lib for both android and iOS. The lib heavily relies on regexes. We’ve had no issues in the past. But we now came across a regex that yields different results on iOS. We are clueless why this happens, does the iOS implementation use a different regex implementation? If so, which one? When doing the same regex in Swift we get the expected result.
    a
    • 2
    • 3
  • b

    Big Chungus

    04/07/2021, 9:50 AM
    Guys, please help! I'm looking for a clever name for a mpp mongo client lib. Naming sure is hard (especially when the original name does not contain a c that you could replace with k) 😀
    r
    k
    m
    • 4
    • 6
  • m

    Mejdi

    04/07/2021, 2:08 PM
    Hey! I am integrating an iOS SDK into my KMM library. Though build works fine, I am facing issues with compilation: Compiler doesn’t resolve my new iOS package import. (that same code I can build as I mentioned) is there anything you can point me towards to solve such issue ?
    • 1
    • 2
  • j

    jw

    04/07/2021, 2:11 PM
    they must not be run on main. all of the APIs should be using
    Default
    as, well, a default.
    d
    k
    +3
    • 6
    • 11
  • j

    Joost Klitsie

    04/07/2021, 3:04 PM
    Hi all! Do people have any example for full stack multiplatform architectures? I am working on a personal project myself, containing a ktor backend, react web app and an android app. This application has an experimental focus on reusing as much code as possible, up until now 25% of the backend code comes from the shared code, and the frontend in itself can share more code than that (obviously 🙂 ) even if the react app and the android app have two different purposes. Therefore I am wondering how others are also experimenting with this and perhaps have some already published articles on this topic, please let me know 🙂
    👍 1
    a
    • 2
    • 8
  • d

    Daniele B

    04/07/2021, 3:45 PM
    SqlDelight question: Possible to remove any of this boilerplate code? I have a database table called “Countries”, for which SqlDelight generated a data class “Countries”. I then have a serializable Repository data class “CountryData”, used by Ktor to serialize the Api response. These two data classes have basically the same properties, and at the moment I need to write this code to match the two objects, which seems to be a lot of boilerplate code: I have to write the same property 3 times. Is it possible to simplify in any way?
    fun LocalDb.getCountriesList() : List<CountryData> {
        return countriesQueries.getCountriesList(
            mapper = { name, population, first_doses, fully_vaccinated ->
                CountryData(name = name, population = population, firstDoses = first_doses, fullyVaccinated = fully_vaccinated)
            }).executeAsList()
    }
    k
    • 2
    • 6
  • c

    Colton Idle

    04/07/2021, 9:15 PM
    Should multi platform projects be opened in Android studio or IntelliJ? I downloaded 2021.1 IJ today and noticed there is a multiplatform compose option in the wizard. But for KMM I've been using AS.
    o
    e
    • 3
    • 4
  • d

    Daniele B

    04/07/2021, 9:22 PM
    is
    measureTimeMillis{}
    not available in CommonMain?
    e
    • 2
    • 2
  • s

    sushma nayak

    04/07/2021, 10:24 PM
    Hi all! I'm. getting a linker error when running the iOS app through Xcode. The app is building and running without error on Android studio though and running through device too. Error:
    ld: warning: ignoring file ****/common/build/cocoapods/framework/common.framework/common, building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64
    Undefined symbols for architecture arm64:
     "_OBJC_CLASS_$_CommonSafeStore", referenced from:
          objc-class-ref in AppCoordinator.o
    ld: symbol(s) not found for architecture arm64
    SafeStore
    is an
    expect/actual class
    . After adding this the issue arose. Is there anything additional that is needed for expect/actual declared classes to run on Xcode?
    i
    m
    y
    • 4
    • 7
  • m

    marzelwidmer

    04/08/2021, 12:30 PM
    Me again 🙂 questions from MOBILE rookie 🙂 is it possible to export the IDEA keybindings and import it in XCODE ? my first tries … was not really a success  Story 😞  I want get in touch with all the KMM stuff but I don’t want learn other shortcuts 🙂
    b
    k
    l
    • 4
    • 8
  • s

    sushma nayak

    04/08/2021, 1:32 PM
    Building a KMM shared library linked iOS project through Xcode on Apple M1 mac failing.
    y
    d
    • 3
    • 3
Powered by Linen
Title
s

sushma nayak

04/08/2021, 1:32 PM
Building a KMM shared library linked iOS project through Xcode on Apple M1 mac failing.
Interesting thing, it runs on Android studio.
y

yousefa2

04/08/2021, 8:54 PM
Since you are on M1 chip which is arm64 you need to switch this part of your config from
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
        if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
            ::iosArm64
        else
            ::iosX64
    iosTarget("ios") {}
to just
iosArm64("ios") {}
d

Dmitriy Tarasevich

04/08/2021, 11:16 PM
or you can build a fat version of it by doing the following
val buildXcFramework by tasks.registering {
    dependsOn("deleteXcFramework")
    group = "build"
    val mode = "Release"
    val frameworks = arrayOf("iosArm64", "iosX64")
        .map {
            kotlin.targets.getByName<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>(it).binaries.getFramework(
                mode
            )
        }
    inputs.property("mode", mode)
    dependsOn(frameworks.map { it.linkTask })
    doLast { buildXcFramework(frameworks) }
}

fun Task.buildXcFramework(frameworks: List<org.jetbrains.kotlin.gradle.plugin.mpp.Framework>) {
    val buildArgs: () -> List<String> = {
        val arguments = mutableListOf("-create-xcframework")
        frameworks.forEach {
            arguments += "-framework"
            arguments += "${it.outputDirectory}/$frameworkName.framework"
        }
        arguments += "-output"
        arguments += xcFrameworkPath
        arguments
    }
    exec {
        executable = "xcodebuild"
        args = buildArgs()
    }
}
➕ 2
View count: 1