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
kotlin-native
  • s

    spierce7

    03/26/2020, 8:39 PM
    I’m using a
    StableRef
    to allow a
    frozen
    object to hold onto a non-frozen object, so that I can create an object that I can create a wrapping object that provides an interface that’s responsible for ensuring access on the right thread. This creates a memory leak though, as
    StableRef
    has to be `dispose`ed when it’s done. Is there any way to get around disposing
    StableRef
    so that I don’t have to add a
    dispose()
    fun on every single one of these interfaces? Is there another way to do this without using
    StableRef
    ?
    d
    k
    26 replies · 3 participants
  • n

    napperley

    03/27/2020, 12:42 AM
    Looks increasingly likely that the memory leaks in my Kotlin Native program come from one or more third party Kotlin Native libraries. Below are the libraries being used by the program: • Ktor Client Curl 1.3.2 (io.ktor:ktor-client-curl:1.3.2) • Ktor Client Serialization Native 1.3.2 (io.ktor:ktor-client-serialization-native:1.3.2) • KotlinX Serialization Runtime Common 0.20.0 (org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.20.0) • Ktor Client Core 1.3.2 (io.ktor:ktor-client-core:1.3.2) • Ktor Client Serialization 1.3.2 (io.ktor:ktor-client-serialization:1.3.2) • Kotlin Common Standard Library 1.3.71
    😱 1
    y
    k
    3 replies · 3 participants
  • s

    spierce7

    03/27/2020, 5:13 AM
    @olonho I want to write a class that doesn’t have to worry about threading concerns at all. It only is ever used by one thread. Then I want to create a wrapper for that class (eventually I want to generate it with a compiler plugin, but for now I’m manually writing it), that exposes the same API, but via suspend functions, and is asynchronous, that delegates to the original class, mostly via
    withContext
    calls. This means that the wrapper will need to be frozen, and the core class that the wrapper delegates too will need to not be frozen. The wrapper has to have a reference to the core class though. How can I accomplish this? Someone mentioned using a
    StableRef
    , which seems like it will do the job, but then it has to be disposed in order to not cause a memory leak for a reference. That means that a
    dispose
    function has to be added to my wrapper. I’d like to not pollute my interface and require an API like that. Is there another way?
    o
    k
    +1
    8 replies · 4 participants
  • m

    mbonnin

    03/28/2020, 11:16 PM
    Can I run a macOS dispatchLoop from
    macosX64Test
    ? I tried calling
    dispatch_main
    manually but it gave me a
    Illegal instruction: 4
    b
    5 replies · 2 participants
  • i

    icarumbas

    03/29/2020, 7:51 PM
    How can i reduce iOS app size? Empty project takes 40mb on my iPhone
    k
    3 replies · 2 participants
  • d

    darkmoon_uk

    03/30/2020, 4:45 AM
    message has been deleted
    m
    1 reply · 2 participants
  • b

    Brendan Weinstein

    03/30/2020, 7:18 AM
    When updating to use kotlin 1.3.71 from 1.3.61 I switched to declaring generics with
    tasks.withType<KotlinCompile> {
      kotlinOptions.freeCompilerArgs += "-Xobjc-generics"
    }
    instead of
    extraOpts("-Xobjc-generics")
    , but I am seeing types returned as Any where I did not before. Any tips on the right way to enable generics for 1.3.71?
    a
    r
    +1
    11 replies · 4 participants
  • s

    Sylvain Patenaude

    03/30/2020, 3:38 PM
    We generated a .framework that worked fine when compiled in Xcode10 but now doesn't compile anymore in Xcode11. Anyone with hints? Thanks in advance!
    b
    4 replies · 2 participants
  • k

    Kris Wong

    03/31/2020, 3:59 PM
    e: Compilation failed: GC overhead limit exceeded * Source files: * Compiler version info: Konan: 1.3.71 / Kotlin: 1.3.71 * Output kind: FRAMEWORK e: java.lang.OutOfMemoryError: GC overhead limit exceeded
    b
    n
    +1
    12 replies · 4 participants
  • s

    spierce7

    03/31/2020, 5:27 PM
    I’ve added an extension function in Kotlin to an objc framework. It’s showing up in Swift code though as a function that you have to pass an instance into. Here is the objc header:
    __attribute__((objc_subclassing_restricted))
    __attribute__((swift_name("RallyAbTestKt")))
    @interface RATRallyAbTestKt : RATBase
    + (void)getExperimentGroup:(id<RATRallyAbTest>)receiver name:(NSString *)name callback:(void (^)(NSString *))callback __attribute__((swift_name("getExperimentGroup(_:name:callback:)")));
    + (void)doInit:(id<RATRallyAbTest>)receiver appName:(NSString *)appName userIdentifier:(NSString *)userIdentifier experiments:(NSArray<RATExperiment *> *)experiments mode:(RATAbTestMode *)mode callback:(void (^)(NSArray<RATExperimentGroup *> *))callback __attribute__((swift_name("doInit(_:appName:userIdentifier:experiments:mode:callback:)")));
    @end;
    The interop documentation shows that it should show up as an extension in Swift. Do I have to do something special to get that to work?
    b
    12 replies · 2 participants
  • p

    Patrick

    03/31/2020, 8:06 PM
    In a c interop, does anyone know why I am getting the error:
    Unresolved reference: __builtin_va_list
    ? I am not sure I understand why this error occurs. The generated Kotlin file has this import:
    import platform.builtin.__builtin_va_list
    , but that import does not exist. Does anyone know why this problem occurs or has any workaround for it?
    n
    a
    12 replies · 3 participants
  • s

    spierce7

    04/01/2020, 3:20 AM
    I’m encountering a
    MutabilityException
    when using the
    native-mt
    version of coroutines with
    Flow
    . I’ve been stuck on this all day and it doesn’t make a ton of sense to me. I’ve re-created the issue on a small scale in the form of tests, one with the exception, one without. It’s difficult to tell if I’m being dense, or if there is a bug that I’m hitting. For some reason the tests never complete when both are in the file. If you comment out
    test2
    , run
    test1
    , let it complete, and then check the stdout from the test, you’ll see the error.
    test1
    has the exception, and
    test2
    doesn’t. https://gist.github.com/ScottPierce/0e687021f34d779708d1f32bfc81e8e2
    b
    2 replies · 2 participants
  • v

    Vlad Balan

    04/01/2020, 8:16 AM
    Hi guys, I wanted to ask what is the current status for using
    protobuf
    with
    Kotlin/Native
    ? If anybody, can provide some useful links for this, I would be thankful.
    k
    d
    +1
    13 replies · 4 participants
  • a

    alex009

    04/01/2020, 9:45 AM
    hi all. anybody know how to fix error:
    e: java.nio.file.NoSuchFileException: /Users/alex/Desktop/work_projects/my-project/dist/konan/konan.properties
    ?
    a
    e
    +1
    13 replies · 4 participants
  • e

    Euler

    04/01/2020, 5:01 PM
    Hi All, I am having a problem when compiling my project. This is the error:
    Task :BcLib:cinteropRUAIos
    Downloading native dependencies (LLVM, sysroot etc). This is a one-time action performed only on the first run of the compiler. Downloading dependency: https://download.jetbrains.com/kotlin/native/libffi-3.2.1-3-darwin-macos.tar.gz (72.6 kiB/72.6 kiB). Done. Extracting dependency: /Users/vnteumr/.konan/cache/libffi-3.2.1-3-darwin-macos.tar.gz into /Users/vnteumr/.konan/dependencies Downloading dependency: https://download.jetbrains.com/kotlin/native/clang-llvm-apple-8.0.0-darwin-macos.tar.gz (393.8 MiB/393.8 MiB). Done. Extracting dependency: /Users/vnteumr/.konan/cache/clang-llvm-apple-8.0.0-darwin-macos.tar.gz into /Users/vnteumr/.konan/dependencies e: /Users/vnteumr/workspace/bc-android/bc-kmp/BcLib/build/classes/kotlin/ios/main/BcLib-cinterop-RUA.klib-build/kotlin/com/ingenico/lar/bc/bc.kt: (31, 23): Unresolved reference: UIAxis e: /Users/vnteumr/workspace/bc-android/bc-kmp/BcLib/build/classes/kotlin/ios/main/BcLib-cinterop-RUA.klib-build/kotlin/com/ingenico/lar/bc/bc.kt: (1345, 78): Unresolved reference: UIAxis e: /Users/vnteumr/workspace/bc-android/bc-kmp/BcLib/build/classes/kotlin/ios/main/BcLib-cinterop-RUA.klib-build/kotlin/com/ingenico/lar/bc/bc.kt: (1437, 70): Unresolved reference: UIAxis It is very strange because the error happened when I was trying to generate a FatFramerkork. After the compile error, I rollback the changes I have done on gradle.build file . However, the error still happen after rollback. Then, I deleted all cache files (.gradle, .idea, .konan) and tried to build again. The same error happens. Have you faced this error? Do you know how to fix it?
    a
    5 replies · 2 participants
  • s

    spierce7

    04/01/2020, 6:52 PM
    I’m compiling a fat framework for iOS and the errors that I’m getting are obfuscated. How do I get non-obfuscated errors from a locally built
    .framework
    ?
    2 replies · 1 participant
  • s

    spierce7

    04/01/2020, 11:42 PM
    Is the Kotlin/native compiler smart enough to take non-caputuring lambdas and make them singleton instances?
    d
    1 reply · 2 participants
  • m

    mbonnin

    04/01/2020, 11:55 PM
    Is there any chance I can make K/N work on Mac OS X 10.11 ? I currently get an error on loading
    /usr/lib/libate.dylib
    a
    1 reply · 2 participants
  • p

    Peter Samokhin

    04/03/2020, 12:31 AM
    Platorm: iOS (mpp), kotlin:
    1.3.71
    , coroutines:
    1.3.5-native-mt
    , ktor:
    1.3.2
    . Can someone explain to me, how is this working: For now, this is not possible to do ktor calls in the background. I know that this is ktor's issue, but only when you are calling
    HttpClient
    from different threads on iOS (according to the github issues), and ktor handles this (does background calls) by itself. In my case, I do such calls only before, but anyway I got
    InvalidMutabilityException
    . How this is possible? A detailed description is below. I have the code like this:
    class IssueReproduce: CoroutineScope {
    	private val dispatcherUi = // on iOS: Dispatchers.Main
    	private val dispatcherDefault = // on iOS: Dispatchers.Default
    	private val job = SupervisorJob()
    	private val api = SomeApi()
    	
    	override val coroutineContext = dispatcherUi + job
    
    	/* ... */
    
        fun checkAuth() {
    	    launch(coroutineContext) {
    	    	// make some call in a background BEFORE
    	        val token = withContext(dispatcherDefault) {
    	            repo.getToken()
    	        }
    
    	        val response = try {
    	            api.doAuth(token)
    	        } catch (e: Throwable) {
    	            // error: 
    	            // kotlin.native.concurrent.InvalidMutabilityException
    	            // mutation attempt of frozen io.ktor.client.request.HttpRequestPipeline@838cd448
    	        }
    	    }
    	}
    }
    Where:
    class SomeApi {
    	private val client = HttpClient(/* ... */)
    
    	suspend fun doAuth(token: String): SomeDataClass {
    		return <http://client.post|client.post> {
    			url(/* ... */)
    			body = /* ... */
    		}
    	}
    }
    But, when I change code to this:
    val token = /* withContext(dispatcherDefault) { */
    	repo.getToken()
    /* } */
    i.e. when I make no calls in the background before calling ktor.HttpClient, all is ok and there are no errors. So, what I'm doing wrong? Removing
    withContext(dispatcherDefault)
    for precending code does the trick, but wrapping ktor calls with
    withContext(coroutineContext)
    or
    withContext(dispatcherUi)
    does not. How preceding code with the call in the background can affect the thread of the following code? And how to fix this? As I mentioned above, I tried to wrap ktor calls with the original thread, but it does not help.
    r
    k
    +1
    9 replies · 4 participants
  • i

    Ian Stewart

    04/03/2020, 1:37 PM
    This commit https://github.com/JetBrains/kotlin-native/pull/3487 re C++ was closed; I’m wondering if there is a “weeks”, “months”, “years” ballpark idea for creating C++/C#? (and I’m aware of the cppsharp solutions being used). Thanks! Addendum: And please feel free to openly chastise me if I’m asking in the wrong place 😉
    m
    1 reply · 2 participants
  • s

    spierce7

    04/03/2020, 8:37 PM
    I’m trying to release a library to my iOS team. The Debug version of the fat framework creates a DSYM folder, which is essential from my understanding to get desymbolicated stack traces. However, it’s also my understanding that the release version does certain optimizations in code. I want the optimizations, but I also want desymbolicated stack traces in production. Is this possible?
    k
    3 replies · 2 participants
  • m

    mbonnin

    04/05/2020, 2:03 PM
    When building an iOS Framework, is it somehow possible to "restrict" the exposed symbols. For an exemple, disregard everything that is in a
    *.internal
    package ?
    k
    2 replies · 2 participants
  • k

    kzotin

    04/07/2020, 12:11 PM
    Hi friends, Wondering, if any of you have tried using Realm-Cocoa/Swift in Kotlin Native project? (Using cinterop or CocoaPods or whatever magic) I'm aware of the following issue :) https://github.com/realm/realm-java/issues/5727 Any other experience of using KMP in existing project with Realm would be very helpful... For now, the closest tactic we came up with is having models as interfaces in KMP with generic
    Storage
    and implementation of
    Storage
    in android/swift module with actual models... Which quite boring! Thanks in advance! 😉
    k
    3 replies · 2 participants
  • l

    Lamberto Basti

    04/07/2020, 1:14 PM
    message has been deleted
    👍 1
    n
    6 replies · 2 participants
  • m

    mbonnin

    04/10/2020, 12:55 AM
    Is it somehow possible to "emulate" the multithreading behavior of K/N on the JVM ? Have the runtime throw on multithreaded accesses on non-freezed objects ? My dev experience is way better on the JVM (debugger & compile time mainly) so if I could catch the freeze exceptions there, that would save me a lot of time.
    a
    k
    +1
    7 replies · 4 participants
  • s

    spierce7

    04/11/2020, 8:04 PM
    Has anyone seen something like this? I’ve got a Kotlin native framework but I’m getting an unexpected error.
    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RATExperiment initWithName:group:]: unrecognized selector sent to instance 0x600001180760'
    a
    1 reply · 2 participants
  • r

    redbassett

    04/12/2020, 5:48 AM
    I’m trying to add dependencies to a K/N project for the first time. In my build file I have the following structure:
    kotlin {
        linuxArm32Hfp("projectname") {
            […]
        }
    
        sourceSets {
            projectnameMain {
                dependencies {
                    implementation 'com.example.package:artifact-name:0.0.0'
                }
            }
        }
    }
    The string passed to
    implementation
    is highlighted in IntelliJ with this warning:
    ‘implementation’ cannot be applied to ‘(java.lang.String)’
    Where do I put dependencies and how do I format them?
    d
    13 replies · 2 participants
  • d

    dazza5000

    04/12/2020, 2:29 PM
    I am new to native development and was curious if we could use kotlin native to target windows xp. Thank you!
    👍 1
    s
    2 replies · 2 participants
  • a

    ademar111190

    04/12/2020, 7:08 PM
    Hi, I just made a hello world with kmp and it is working on android and ios. Now i'm trying to port the same code to linux, but I'm not finding much material about, anyone knows an open source project using kmp on linux apps?
    d
    n
    +1
    5 replies · 4 participants
  • a

    Arkadii Ivanov

    04/12/2020, 9:54 PM
    I just want to thank the Kotlin/Native team for such a significant improvement in build time in 1.3.70. You rock!
    ➕ 12
    🔥 5
    :tnx: 2
    s
    k
    8 replies · 3 participants
Powered by Linen
Title
a

Arkadii Ivanov

04/12/2020, 9:54 PM
I just want to thank the Kotlin/Native team for such a significant improvement in build time in 1.3.70. You rock!
➕ 12
🔥 5
:tnx: 2
s

svyatoslav.scherbina

04/13/2020, 11:26 AM
Thank you for the feedback! It is very important for us to know that our efforts actually affect real projects.
Btw, how much have your build time improved with 1.3.70?
a

Arkadii Ivanov

04/13/2020, 11:36 AM
I don't have any metrics, feels like 2x or even more.
According to GitHub Actions history, for iOS it is dropped from ~13mins to ~5 mins.
🔥 3
For Linux approximately from ~8.5 mins to 4.5 mins.
s

svyatoslav.scherbina

04/13/2020, 11:46 AM
We’ve implemented two relevant features in 1.3.70 — “compiler caches” and running Kotlin compiler in Gradle daemon. Compiler caches aren’t enabled for Linux but enabled for iOS (simulator). So Linux build time improvement is probably the result of using Gradle daemon. I guess you have lot of compiler invocations in your build.
❤️ 2
a

Arkadii Ivanov

04/13/2020, 12:04 PM
Yes I have more more than 10 modules currently. Also I'm using different hosts for different targets when building on CI. E.g. linuxX64 is built on Ubuntu, iOS is on macOS, non native targets are on Ubuntu. And they run in parallel.
:tnx: 1
k

Kavan

04/14/2020, 12:31 PM
1.4.0 even more fun
View count: 4