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

    Marc Knaup

    06/10/2019, 10:26 PM
    Finally, iOS app archiving is successful! First app for me which includes a multiplatform core! Shared code between iOS, Android and back-end. Now waiting for the Apple Developer Program Enrollment to complete to actually release it 🙂 It was quite a rocky ride but I think it will be worth it 💪
    💯 14
    p
    k
    • 3
    • 4
  • m

    Marc Knaup

    06/11/2019, 2:58 PM
    Xcode profiler on iOS Simulator, 5s wall time 😅 I need at least move that off the main thread.
    😱 2
    s
    s
    • 3
    • 7
  • m

    Marc Knaup

    06/11/2019, 4:06 PM
    On iOS, does the following make sense to start coroutines using whatever the current dispatch queue is?
    private object CurrentQueueDispatcher : CoroutineDispatcher() {
    
    	override fun dispatch(context: CoroutineContext, block: Runnable) {
    		dispatch_async(dispatch_get_current_queue()) {
    			block.run()
    		}
    	}
    }
    …
    GlobalScope.launch(CurrentQueueDispatcher) { … }
    Also,
    dispatch_async
    or
    dispatch_sync
    ? The documentation doesn't state whether it's okay to block here or not.
    b
    d
    +2
    • 5
    • 32
  • e

    EnricCamarero

    06/12/2019, 8:32 AM
    Hi guys! I’m looking for how to make a mpp project work with the following structure: - MPP Kotlin Module [domain] - iOS App [iosApp] So far my only option to get it to work is manually move the generated framework to my iOS xCode Project. Nonetheless I get this “image not found” runtime error on a daily basis. Is there any way to bind the build process of the iOS App to build and bind the Kotlin framework? I’ve been all over Google looking for an answer with no success so far…
    r
    • 2
    • 5
  • j

    Jonas Bark

    06/12/2019, 8:42 AM
    FatFrameworkTask: anyone seen these errors when trying to integrate the Framework as embedded framework and running it on a Device?
    dyld: Library not loaded: @rpath/Redacted.framework/Redacted
      Referenced from: /var/containers/Bundle/Application/89E8B214-46AC-4251-B0EE-25222E57D0F7/konfswift.app/konfswift
      Reason: no suitable image found.  Did find:
    	/private/var/containers/Bundle/Application/89E8B214-46AC-4251-B0EE-25222E57D0F7/konfswift.app/Frameworks/Redacted.framework/Redacted: no matching architecture in universal wrapper
    The gradle task used:
    tasks.create("debugFatFramework", FatFrameworkTask::class) {
            baseName = "Redacted"
            from(
                iosArm32.binaries.getFramework("DEBUG"),
                iosArm64.binaries.getFramework("DEBUG"),
                //iosX64.binaries.getFramework("DEBUG")
            )
            destinationDir = File(buildDir, "build")
            group = "Universal framework"
            description = "Builds a universal (fat) debug framework"
        }
    r
    s
    • 3
    • 11
  • a

    Andy Victors

    06/12/2019, 11:37 AM
    [iOS] I'm getting a warning
    'swift_name' attribute has invalid identifier for base name
    for all autogenerated `serializer()`classes. (Kotlin:
    1.3.31
    , Serialization:
    0.11.0
    ) Should I worry about it?
    s
    • 2
    • 1
  • t

    tylerwilson

    06/12/2019, 1:53 PM
    AppCode + Kotlin single step debugging = Sleep. Is this an IDE, plug-in compiler issue? Can we hope for relief?
    k
    • 2
    • 18
  • t

    tylerwilson

    06/12/2019, 2:51 PM
    One more AppCode issue I have run into: some code I had developed with IntelliJ IDEA Community with Kotlin MP, when moved over to an AppCode does not resolve some Kotlinx Serialization uses.
    • 1
    • 1
  • a

    Andrey Makovskiy

    06/12/2019, 8:35 PM
    Hello for all! Can anybody help with error "kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen". Problem is that object is created in main thread on iOS and exception thrown from constructor. When and why object become frozen?
    m
    a
    j
    • 4
    • 18
  • b

    Bhattachar

    06/12/2019, 9:17 PM
    Please find my build.gradle Also, can you please let me know: 1. Should I create any folders for the build or will folders be automatically created? 2. To generate build, should we “run app” or “Sync Project With Gradle Files”?
    l
    • 2
    • 7
  • e

    EnricCamarero

    06/13/2019, 10:49 AM
    Hi there! Any idea on why KotlinTargetContainerWithPresetFunctions exposes android() but it won’t work inside the kotlin block of a build.gradle ?
    Extension with name 'android' does not exist. Currently registered extension names: [ext, kotlin, defaultArtifacts, reporting, sourceSets, java]`
    build.gradle
    plugins {
        kotlin("multiplatform") version "1.3.31"
    }
    
    kotlin {
        android()
    }
    r
    r
    • 3
    • 3
  • f

    Fail

    06/13/2019, 12:56 PM
    Hi devs! I create a new multiplatform project with Android and IOS. (It show a current platform) At android run perfectly but when I run the code on Xcode I have an error: /Users/.../Xcode/DerivedData/iosApp-axkbbwgyarknnvehlgjsmvkylxqc/Build/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/app.build/Script-F861D812207FA4320085E80D.sh: line 2: /Users/dev/Documents/MultiplatformTest/iosApp/../gradlew: No such file or directory What a file I need? Where can get it?
    s
    a
    c
    • 4
    • 4
  • f

    Fail

    06/13/2019, 3:45 PM
    Hi again. I want to add ktor library to my project. I paste dependence in project:
    iosMain {
                dependencies {
                    implementation "io.ktor:ktor-client-ios:$ktor_version"
                }
            }
    But it not compiling. Error:
    > Task :app:linkDebugFrameworkIos
    Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_UIDevice", referenced from:
          objc-class-ref in combined.o
    ld: symbol(s) not found for architecture x86_64
    e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
    
    > Task :app:linkDebugFrameworkIos FAILED
    a
    • 2
    • 1
  • a

    Andrei Marshalov

    06/14/2019, 11:07 AM
    Hello, i have a question about using cinterop in kotlin native. I need to pass kotlin string to C function with signature like this:
    someFunctionFromC(data: kotlinx.cinterop.CValuesRef<libmylib.GByteVar /* = kotlinx.cinterop.UByteVarOf<libmylib.GByte /* = kotlin.UByte */> */>?)
    So, i tried to use ‘cstr’ how it described here (https://kotlinlang.org/docs/tutorials/native/mapping-strings-from-c.html):
    val kotlinString = "qwerty"
    someFunctionFromC(kotlinString.cstr)
    but i get type mismatch:
    Type mismatch:
    Required : CValuesRef<GByteVar /* = UByteVarOf<GByte /* = UByte */> */>?
    Found : CValues<ByteVar /* = ByteVarOf<Byte  /*>
    So i need to pass in C function not
    const char* cstring
    , but
    const unsigned char* cstring
    Solution that i found (https://github.com/JetBrains/kotlin-native/blob/master/INTEROP.md):
    kotlinString.toUtf8().toUByteArray().usePinned { kString ->
        someFunctionFromC(kString.adressOf(0))
    }
    It work, but doesn’t look well. Maybe someone can suggest a better way?
    m
    o
    • 3
    • 4
  • f

    Fudge

    06/14/2019, 12:15 PM
    Anyone know how to get code coverage working for common code in multiplatform projects? When I'm running coverage it seems to only track
    jvmMain
    code.
    h
    • 2
    • 5
  • k

    Kruger Brent

    06/14/2019, 3:21 PM
    Does a C-library compiled with cinterop tool support Android app as well or is it just for the iOS app? If so, how would a build.gradle file look like that has a cinterop tag to build a klib file for both the platforms. I am unable to make this klib work for android right now. Any ideas?
    l
    s
    • 3
    • 2
  • m

    mbonnin

    06/14/2019, 6:07 PM
    Can I convert a kotlin
    ByteArray
    to a
    kolinx.io.core.Input
    ? I'm mainly interested by the `readByte()`/`readInt()` methods so it should be doable by hand but would prefer not reinventing the wheel if possible.
    • 1
    • 1
  • c

    cafonsomota

    06/14/2019, 7:14 PM
    hello all, I’m trying to add a Kotlin JS module to an existing Android/iOS multiplatform project - but I seem to keep having some errors. I’m not sure if this is the best approach but my current project structure is to have:
    - src/androidMain
    - src/iOSMain
    - src/jsMain
    and my app/build.gradle follows the same approach, having all these modules on the dependencies:
    sourceSets {
            commonMain {
                dependencies {
                    implementation kotlin('stdlib-common')
                    ...
                }
           }
           androidMain...
           iOSMain...
           jsMain...
    at this moment I’ve managed to compile the project both for android and iOS and my js module is capable to access to commonMain (shared code). However, it seems that I’m unable to compile the JavaScript itself 😕. Any idea what I could be doing wrong?
    l
    h
    • 3
    • 10
  • l

    louiscad

    06/15/2019, 2:02 PM
    I'm seeing several multiplatform libraries publishing to bintray using version
    1.8.4-jetbrains-5
    of the bintray gradle plugin instead of the jfrog official 1.8.4 version. Why so? Didn't found any sources for it, nor any documentation regarding it…
    ➕ 2
    d
    g
    +4
    • 7
    • 68
  • j

    Jurriaan Mous

    06/16/2019, 11:37 AM
    I have a Java library which has the following signature:
    public interface Options<T extends Options>
    It uses
    T
    to return self so it can chain method calls. I want to make this interface available to multiplatform with expect/actual so I can also expose the implementing classes with Options interface with expect/actual through a typealias. The actual:
    actual typealias Options<T> = AliasedOptions<T>
    If I put
    expect interface Options<T: Options<*>>
    the actual succeeds but expect fails with
    Violation of Finite Bound Restriction for Options
    If I put
    expect interface Options<T: Options<T>>
    the expect succeeds but the actual fails with
    Actual typealias 'DBOptionsInterface' has no corresponding expected declaration
    The following declaration is incompatible because upper bounds of type parameters are different:
        public expect interface Options<T : Options<T> /* = Options<T> */>
    I have no control over the java library. Are there options to work around this? Or is my only option to copy all the expected methods to all implementing classes and ignore the interfaces?
    • 1
    • 1
  • n

    nestserau

    06/17/2019, 10:41 AM
    Guys, I’ve made a test run of my app on iOS 13 beta 1, and the network operations in my Kotlin MPP library pretty much stopped working. Is this something you are aware about, or should I provide more info for you to be able to fix it?
    a
    l
    s
    • 4
    • 21
  • p

    Patrick Jackson

    06/17/2019, 3:06 PM
    Hi All, a port of Redux to Kotlin multiplatform here: https://www.reduxkotlin.org . Currently a straight port of JS Redux, Thunk, and a Reselect implementation. Supports all platforms supported by Kotlin. Goal of project is to provide a standard on which an ecosystem of middleware/store enhancers/dev tools can grow. There's been several libs, now seems like a good time to set a common core to build upon. Feedback and contributions are welcome, and feel free to DM me. No samples for the time being, hope to have some up in the coming weeks.
    a
    • 2
    • 3
  • b

    Benjamin Charais

    06/17/2019, 8:43 PM
    Hey there all, I’ve been putting together a multiplatform project that will support atleast 3 different products for my company across mobile platforms. I’ve got android working no problem, but today I was working on implementing my iOS portion and I’m running into an issue I am struggling to handle. I assume this is due to my not having any experience in iOS. The app will work with non-ktor code I have everything working up to producing the framework and being able to reference it in code. When I attempt to do anything with ktor for my network, I receive a
    EXC_BAD_ACCESS (code=1, address=0x8)
    in reference to
    ktor_mutex_create
    My versions and implementations: top build.gradle
    buildscript {
        ext.kotlin_version = '1.3.31'
        ext.coroutines_version = '1.2.1'
        ext.klockVersion = "1.4.0"
      
        ext.serialization_version = "0.10.0"
        ext.ktor_version = '1.1.4'
    
        ext.dokka_version = '0.9.17'
            dependencies {
            classpath 'com.android.tools.build:gradle:3.4.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
            classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
    
            classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$dokka_version"
    
            classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta04'
    
            classpath "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
            classpath "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
            classpath "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
        }
    common build.gradle
    iOSMain.dependencies {
                api kotlin('stdlib')
                implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutines_version"
                implementation "io.ktor:ktor-client-ios:$ktor_version"
                implementation "io.ktor:ktor-client-json-native:$ktor_version"
                implementation "io.ktor:ktor-client-logging-native:$ktor_version"
                implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serialization_version"
            }
    The last reference it talks about is
    kfun:kotlinx.cinterop.<get-rawValue>@kotlinx.cinterop.CPointer<#STAR>?.()ValueType at Types.kt
    this is in reference to
    utils.ktor_mutex_create
    o
    e
    • 3
    • 5
  • m

    msink

    06/18/2019, 9:03 AM
    1.3.40 is on the way: https://dl.bintray.com/kotlin/kotlin-dev/org/jetbrains/kotlin/multiplatform/org.jetbrains.kotlin.multiplatform.gradle.plugin/1.3.40/
    🎉 1
    👀 5
    👍 9
    l
    • 2
    • 4
  • j

    Jan Stoltman

    06/18/2019, 10:33 AM
    Is there a way to use Stately https://github.com/touchlab/Stately together with K/JS?
    k
    • 2
    • 4
  • a

    Andrei Marshalov

    06/18/2019, 11:35 AM
    Hi all, is there a way to make expect/actual member function private?
    s
    • 2
    • 2
  • s

    spierce7

    06/19/2019, 10:02 PM
    Has there been any wind of a JetBrains mpp date library for Kotlin? There is something called klock on github, but dates are difficult to do right, so I'm not sure I trust it.
    l
    s
    +2
    • 5
    • 11
  • f

    Fail

    06/20/2019, 8:50 AM
    Hi there! Have is some solution with generics at Swift? I see it like Any in swift. Is it my mistake or generics not supported?
    a
    • 2
    • 3
  • j

    Jurriaan Mous

    06/20/2019, 9:06 AM
    Is there a working example with in IDE running tests for macOS and JS? When I upgrade my multiplatform project to 1.3.40 the tests suddenly don't run except in the JVM. Also in a default IDE kotlin multiplatform project they don't run. I have Intellij IDEA Ultimate 2019.1.3
    l
    s
    • 3
    • 11
  • e

    EnricCamarero

    06/20/2019, 10:41 AM
    Hi fellows! I’m using the Cocoapods integration with Kotlin Mpp. Everything works great except not all methods get converted to my .framework file. Do you know what is going on? Is this a bug or a feature? Here goes my Kotlin class and the .h file generated:
    __attribute__((swift_name("Repository")))
    @protocol DomainRepository
    @required
    - (DomainResult *)getDataSync __attribute__((swift_name("getDataSync()")));
    @end;
    interface Repository {
        suspend fun getData(): Result<List<Song>>
        fun getDataSync() : Result<List<Song>>
    }
    m
    k
    +2
    • 5
    • 5
Powered by Linen
Title
e

EnricCamarero

06/20/2019, 10:41 AM
Hi fellows! I’m using the Cocoapods integration with Kotlin Mpp. Everything works great except not all methods get converted to my .framework file. Do you know what is going on? Is this a bug or a feature? Here goes my Kotlin class and the .h file generated:
__attribute__((swift_name("Repository")))
@protocol DomainRepository
@required
- (DomainResult *)getDataSync __attribute__((swift_name("getDataSync()")));
@end;
interface Repository {
    suspend fun getData(): Result<List<Song>>
    fun getDataSync() : Result<List<Song>>
}
m

marstran

06/20/2019, 10:42 AM
Triple backticks (```) for code blocks 😉
e

EnricCamarero

06/20/2019, 10:43 AM
thnks! 😉
k

kpgalligan

06/20/2019, 10:45 AM
suspend I would assume is the issue
r

ribesg

06/20/2019, 10:59 AM
You obviously can’t use coroutines in ObjC/Swift
l

louiscad

06/20/2019, 11:48 AM
You need to write bridge code to use callbacks (beware of handling cancellation properly)
View count: 6