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

    Andrew Steinmetz

    11/11/2021, 8:43 PM
    Has anybody tried converting a KMM project that was created with Android studio to one that would work with App code? I saw this article and liked the ability to refactor swift code when the kotlin code is changed and was just curious what that experience was like if I were to do that to an existing project of mine.
    b
    t
    • 3
    • 2
  • n

    Nacho Ruiz Martin

    11/12/2021, 5:19 PM
    Hey! 👋 Is it possible to distribute a KMP module as a pure Framework (or w/e the name is for Libraries in iOS ecosystem)? I would want my iOS counterparts not to have to build the module but receive it as a… Pod dependency? Is there any way to do this or it’s mandatory for them to have the Java SDK and such to build it locally?
    a
    • 2
    • 6
  • b

    Brian Donovan

    11/12/2021, 7:15 PM
    Hey! Any documentation to add flavours for KMM?
    b
    • 2
    • 3
  • b

    Brian Donovan

    11/12/2021, 10:13 PM
    This is inside my android main, how can I access from my shared. Is there another library I need to install?
    s
    p
    e
    • 4
    • 18
  • m

    Marco Signoretto

    11/14/2021, 10:11 AM
    Irrespective of your views on mocks versus fakes, sometimes, mocks are useful. The problem is, how do you mock in KMP projects? We spent countless hours thinking about this problem and we are happy to share our new project, MockingBird, which aims to solve this problem. Would love some feedback from the community and ideas on how we can improve this and make it better. small onboarding article: https://www.msignoretto.com/blog/mockingbird_getstarted and official Github repository: https://github.com/careem/mockingbird
    👏 6
    :kotlin-intensifies: 15
    👍 6
    🎉 15
    b
    m
    • 3
    • 5
  • p

    Pavel Repkin

    11/15/2021, 6:09 AM
    I’m not able to plug in Cocoa Pods. Following the tutorial https://kotlinlang.org/docs/native-cocoapods.html#add-a-dependency-on-a-pod-library-from-the-cocoapods-repository Getting an error while gradle synching. Exception in thread “main” java.lang.Error: /var/folders/rf/3423_cyd1s36lym23zw40mkm0000gn/T/11328760320704443198.m1️⃣9: fatal error: could not build module ‘AFNetworking’ I have no clue how to get through. Adding a Cocoa Pod library to our project is essential. Please help! cocoapods section in the build.gradle.kts cocoapods { ios.deploymentTarget = “13.5" summary = “CocoaPods test library” homepage = “https://github.com/JetBrains/kotlin” pod(“AFNetworking”) { version = “~> 4.0.1" } } My setup Mac OS Monterey 12.0.1 ruby 2.6.0p0 (had to downgrade because of a problem with cocoapods-generate install) cocoapods 1.11.2 cocoapods-generate 2.2.2 Android Studio Arctic Fox 2020.3.1 Patch 3 Build log.
    Task 😒hared:generateDefAFNetworking
    Task 😒hared:podDownload UP-TO-DATE
    Task 😒hared:generateDummyFramework UP-TO-DATE
    Task 😒hared:podspec
    Task 😒hared:podGenIOS
    Task 😒hared:podSetupBuildAFNetworkingIphonesimulator
    Task 😒hared:podBuildAFNetworkingIphonesimulator
    Task 😒hared:cinteropAFNetworkingIos
    Exception in thread “main” java.lang.Error: /var/folders/rf/3423_cyd1s36lym23zw40mkm0000gn/T/11328760320704443198.m1️⃣9: fatal error: could not build module ‘AFNetworking’ at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:192) at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:68) at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14) at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:531) at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:268) at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:76) at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45) at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:38) at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:60)
    Task 😒hared:cinteropAFNetworkingIos FAILED
    7 actionable tasks: 6 executed, 1 up-to-date
    v
    • 2
    • 5
  • h

    Hossein Amini

    11/15/2021, 8:21 AM
    Hi all! I’m using the Ktor MockEngine in the commonTest but when I run the test units on iOS it says:
    kotlin.Error: Ktor native HttpClient requires kotlinx.coroutines version with native-mt suffix (like 1.3.9-native-mt). Consider checking the dependencies
    I’m currently using this dependency in the commonMain
    org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0-native-mt
    And there is no issue when I run the app on the iOS but when I run test units on the iOS I get the error I mentioned above. How can I fix it?
    t
    h
    • 3
    • 6
  • s

    salomonbrys

    11/15/2021, 11:22 AM
    Hey guys. Funny enough, I also want to announce a new Kotlin/Multiplatform mocking library: Micro-Mock. It uses KSP to generate mocks, and more or less replicates “classic” mocking systems. Here’s a sample:
    class MyTest {
        @set:Mock lateinit var view: View
        @set:Fake lateinit var model: Model
        lateinit var controller: Controller
    
        val mocker = Mocker()
        @BeforeTest fun setUp() {
            mocker.reset()
            injectMocks(mocker)
            controller = Controller(view = view, firstModel = model)
        }
    
        @Test fun controllerTest() {
            mocker.on { view.render(isAny()) } returns true
            controller.start()
            mocker.verify { view.render(model) }
        }
    }
    The following limitations apply: • Mocking only applies to interfaces • Faking only applies to concrete trees The processor generates: • Mocks of interfaces, allowing to mock behaviour & verify calls. • Fakes of data classes, filling them of nulls, zeros, empty strings, and alike. • Injector for test classes. You’ll find it here : https://github.com/Kodein-Framework/Micro-Mock We are using this in some of our own Multiplatform tests. I hope it will be useful to the community 😉
    🎉 4
    👍 6
    :kotlin-intensifies: 7
    b
    • 2
    • 1
  • a

    Andrew O Hart

    11/15/2021, 12:46 PM
    Hey all, hows things! Working on a multiplatform project, and we need to encrypt our db. Using sql-cipher on android and its working fine but for the ios side its proving a bit tricker. We don't want to use cocoapods because of the overhead, so we were hoping to build the lib and link it. I'm having some issues with this and was wondering if anybody ran into something similar? SQLCipher readme says you can run:
    ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" \
    	LDFLAGS="/opt/local/lib/libcrypto.a"
    However this gives me an error saying "C compiler cannot create executables" Also I saw on the forums somebody said to try:
    ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC -I/usr/local/opt/openssl/include/" LDFLAGS="/usr/local/opt/openssl/lib/libcrypto.a"
    This looks like it builds but at the end says "error: Library crypto not found. Install openssl!" but I have already installed openssl via homebrew. Basically I need to get the .a file build and bring it into the ios part of the multiplatform project and then bring in the .h file and create the .def file but its proving trickier than I thought. I know this isn't exactly related to multiplatform specifically but I thought maybe somebody encountered something similar and could help. Thanks!
    r
    v
    • 3
    • 42
  • l

    Lukasz Kalnik

    11/15/2021, 12:49 PM
    Ktor needs an SLF4J implementation for logging to work. For Android there is Logback. How do you handle logging on iOS? Is it possible to use Kermit for Ktor logging there?
    m
    r
    m
    • 4
    • 6
  • a

    Alexander Suraphel

    11/15/2021, 4:59 PM
    What do you recommend for background work instead of WorkManager to do background work?
    b
    • 2
    • 7
  • a

    Anton Afanasev

    11/15/2021, 5:21 PM
    Hi. I wonder if this looks like a valid way to call suspend function from within commonMain:
    class TestClass {
        private val dispatcher = CoroutineScope(Dispatchers.Main + SupervisorJob())
        
        fun someAction() {
            //do something
            dispatcher.launch {
                requestWithKtor()
            }
        }
        
        suspend fun requestWithKtor() {
            //do some networking
        }
    }
    g
    • 2
    • 1
  • m

    Mendess

    11/15/2021, 6:25 PM
    how do value classes interact with multiplatform code? How do I know what is the generated JS, Native (iOS) code for them? Tried to find some documentation on it but I can't seem to find any
    g
    • 2
    • 1
  • w

    William Reed

    11/15/2021, 8:01 PM
    are kotlin multiplatform projects still considered alpha? the kotlin official page says so, but it seems outdated with some other stuff it references
    c
    • 2
    • 1
  • b

    Brian Donovan

    11/15/2021, 8:56 PM
    Hey all, Not sure why I can’t grab baseUrl. Any thoughts? Thanks
    :not-kotlin: 3
    l
    • 2
    • 1
  • l

    Lilly

    11/15/2021, 11:58 PM
    When I plan to have a pure kotlin library but for now only want to support jvm target, should I create a kotlin JVM library or a mmp library? Is there any difference between jvm and mmp library if I would define only jvm target in mmp library?
    c
    u
    m
    • 4
    • 10
  • j

    Jolas

    11/16/2021, 5:48 AM
    Is there any documentation for native database encryption in SQLDelight? I see that SQLDelight(v1.5.2) offers to set
    encryptionConfig = DatabaseConfiguration.Encryption(key: String?, rekey: String?)
    and I suppose it works fine. But is there any documented behavior for using
    DatabaseConfiguration.Encryption
    ?
    • 1
    • 3
  • s

    saket

    11/16/2021, 6:06 AM
    I'm trying to compile my project on macOS running on an m1 machine, but it's failing with this error:
    * What went wrong:
    A problem occurred configuring project ':common'.
    > kotlin.native.cocoapods.target property was dropped in favor of kotlin.native.cocoapods.platform and kotlin.native.cocoapods.archs. 
      Podspec file might be outdated. Sync project with Gradle files or run the 'podspec' task manually to regenerate it.
    Am I understanding the message correctly that compilation is failing because my podspec file is outdated? Running
    podspec
    task doesn't seem to change anything.
    v
    s
    • 3
    • 6
  • d

    darkmoon_uk

    11/16/2021, 1:28 PM
    Tip: Added a
    standalone
    module to my Desktop project that includes both the client & server, and then provides a
    main
    function to start the Ktor server embedded in the same runtime as the client. It is insanely convenient for development 😂 No more juggling client/server instances to test-drive basic integrations. The whole system runs as one, debugs as one.
    👍 1
    b
    • 2
    • 1
  • r

    Rak

    11/16/2021, 4:41 PM
    Hi, if i create a kmm shared library as a separate project, then I won’t have a root build.gradle.kts file with a
    buildscript
    block. I need one to get the sqldelight plugin to work. What is the workaround?
    g
    • 2
    • 6
  • b

    Brian Donovan

    11/16/2021, 6:18 PM
    Hello all, If I make a singleton instance on my shared, will it be accessible on iOs?
    w
    • 2
    • 1
  • u

    ultraon

    11/16/2021, 9:29 PM
    JFYI there is an issue with updating
    KMM
    plugin
    0.3.0
    for
    Android Studio Bumblebee Beta3
    k
    g
    • 3
    • 3
  • j

    Jim

    11/16/2021, 10:56 PM
    how can I lock my jvm dependencies in a multiplatform project?
    h
    • 2
    • 2
  • h

    Hossein Amini

    11/17/2021, 11:24 AM
    Hi All Is there any way to use Android Context in the KMM test?
    h
    g
    • 3
    • 7
  • b

    Brian Donovan

    11/17/2021, 1:52 PM
    Hello All, I’m having issue with email validation on iOS side. Is it because I am using android.util? Any solution to this? Thanks
    s
    • 2
    • 3
  • b

    Brian Donovan

    11/17/2021, 8:16 PM
    Hi All, how can I read a file from resource directory in shared -> commonMain
    m
    a
    • 3
    • 7
  • j

    Javier

    11/17/2021, 8:31 PM
    I am getting this error
    SyntaxError
    when I enable js in a project that only has common code. I think it is related to use regex in the lib, anyone know what can be happening?
    m
    • 2
    • 21
  • n

    Nils Becker

    11/18/2021, 7:46 AM
    Hi everyone At dreipol we developed a new framework building on Apple’s DeviceCheck and Google’s SafetyNet to restrict API access to genuine installations of your app. It’s compatible with KMM and you can read all about it in our blog post.
    l
    • 2
    • 1
  • p

    Pavel Repkin

    11/18/2021, 9:11 AM
    I’m having an issue with CocoaPod integration. I have created a new KMM project from Android Studio “New Project/KMM Application” Then added a basic CocoaPod dependency on AFNetworking just as described in the tutorial https://kotlinlang.org/docs/native-cocoapods.html#add-a-dependency-on-a-pod-library-from-the-cocoapods-repository Then I have updated Platform class with AFNetworking usage.
    import platform.UIKit.UIDevice
    import cocoapods.AFNetworking.*
    actual class Platform actual constructor() {
    actual val platform: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion +
    " " + AFNetworkingReachabilityNotificationStatusItem
    }
    After that I’m getting linkage error while trying to build an iOS app.
    Undefined symbols for architecture x86_64:
    "_AFNetworkingReachabilityNotificationStatusItem", referenced from:
    _cocoapods_AFNetworking_AFNetworkingReachabilityNotificationStatusItem_getter_wrapper12 in shared(result.o)
    ld: symbol(s) not found for architecture x86_64
    How to solve this error? My configuration Android Studio Arctic Fox 2020.3.1 Patch 3 Kotlin 1.6.0 XCode 13 ruby 2.6.0p0 (had to downgrade because of a problem with cocoapods-generate install) cocoapods 1.11.2 cocoapods-generate 2.2.2 Mac OS Monterey 12.0.1
    ✅ 1
    v
    k
    • 3
    • 4
  • j

    Javier

    11/18/2021, 2:26 PM
    I am curious to know if it is in the roadmap (or if it will be even possible) to run Windows tests on macOS. Context: https://twitter.com/RussHWolf/status/1461142170165993472?s=20
    👀 1
    h
    r
    • 3
    • 2
Powered by Linen
Title
j

Javier

11/18/2021, 2:26 PM
I am curious to know if it is in the roadmap (or if it will be even possible) to run Windows tests on macOS. Context: https://twitter.com/RussHWolf/status/1461142170165993472?s=20
👀 1
h

hfhbd

11/18/2021, 2:32 PM
How could you test the Windows API, especially files on other targets? Does MingW support this?
r

russhwolf

11/18/2021, 2:50 PM
It's not just a Windows thing. The same is true of Linux targets.
View count: 13