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

    Vlad Balan

    02/13/2020, 1:07 PM
    Hi all, I am currently trying to build a small project for arm64. I wanted to ask if it is possible to create a custom target. I mean something different than using:
    kotlin{
     linuxArm64()
    }
    I am interested in creating a custom target for arm64 where I can specify what compiler/linker options I want to use. Thanks in advance!
    d
    • 2
    • 4
  • a

    andreasmattsson

    02/14/2020, 1:39 PM
    Anyone know if there have been any intentionally breaking changes in "Kotlin Native Cocoapods" or objc cinterop integration lately? Am trying to upgrade from kotlin 1.3.50 to 1.3.61, and it's failing on a pod that was previously working.
    -kotlin_version=1.3.50
    -kotlin_coroutines_version=1.3.0
    -kotlin_serialization_version=0.12.0
    +kotlin_version=1.3.61
    +kotlin_coroutines_version=1.3.3
    +kotlin_serialization_version=0.14.0
    I'm getting this error:
    > Task :Common:generateDefFlutter UP-TO-DATE
    > Task :Common:cinteropFlutterIOS
    > Task :Common:generateDefReactiveObjC
    > Task :Common:cinteropReactiveObjCIOS FAILED
    Exception in thread "Thread-3" java.lang.AssertionError: Assertion failed
    	at org.jetbrains.kotlin.native.interop.indexer.NativeIndexImpl.convertFunctionType(Indexer.kt:654)
    	at org.jetbrains.kotlin.native.interop.indexer.NativeIndexImpl.convertBlockPointerType(Indexer.kt:691)
    	at org.jetbrains.kotlin.native.interop.indexer.NativeIndexImpl.convertType(Indexer.kt:610)
    	at org.jetbrains.kotlin.native.interop.indexer.NativeIndexImpl.convertType$default(Indexer.kt:507)
    	at org.jetbrains.kotlin.native.interop.indexer.NativeIndexImpl.getTypedef(Indexer.kt:420)
    	at org.jetbrains.kotlin.native.interop.indexer.NativeIndexImpl.indexDeclaration(Indexer.kt:772)
    	at org.jetbrains.kotlin.native.interop.indexer.IndexerKt$indexDeclarations$$inlined$withIndex$lambda$1.indexDeclaration(Indexer.kt:985)
    	at org.jetbrains.kotlin.native.interop.indexer.UtilsKt$indexTranslationUnit$1$indexerCallbacks$1$4.invoke(Utils.kt:428)
    	at org.jetbrains.kotlin.native.interop.indexer.UtilsKt$indexTranslationUnit$1$indexerCallbacks$1$4.invoke(Utils.kt)
    	at kotlinx.cinterop.JvmCallbacksKt$createStaticCFunctionImpl$$inlined$ffiClosureImpl$3.invoke(JvmCallbacks.kt:489)
    	at kotlinx.cinterop.JvmCallbacksKt$createStaticCFunctionImpl$$inlined$ffiClosureImpl$3.invoke(JvmCallbacks.kt)
    	at kotlinx.cinterop.JvmCallbacksKt.ffiFunImpl(JvmCallbacks.kt:448)
    	at kotlinx.cinterop.JvmCallbacksKt.ffiFunImpl0(JvmCallbacks.kt:435)
    
    FAILURE: Build failed with an exception.
    I'm using two Pods defined in my
    cocoapods
    -block:
    cocoapods {
                pod('Flutter', library_version)
                pod('ReactiveObjC', "~> $reactive_objc_version")
            }
    (reactive_objc_version is 3.1)
    a
    • 2
    • 10
  • m

    msink

    02/16/2020, 8:47 AM
    "Native Debugging Support" does not work for me, on Windows10 / IDEA2020.1 / 1.3.70EAP2
    k
    • 2
    • 6
  • u

    ursus

    02/16/2020, 1:37 PM
    noob question, if I were to build a CI to check if ios integration works, I'd need for it to be a mac, right?
    a
    • 2
    • 1
  • k

    kpgalligan

    02/16/2020, 7:26 PM
    Global
    val
    properties with
    @SharedImmutable
    work as expected, but if you use a
    var
    , the
    @SharedImmutable
    doesn’t apply. Logically that makes sense, but it seems like that may be confusing in situations where people try it. I think it would be better to have it frozen, or maybe a compiler failure, but right now it seems like the annotation is simply ignored. Thoughts?
    b
    • 2
    • 2
  • n

    Nikita Khlebushkin

    02/17/2020, 1:22 AM
    Hello there, I have an Android/iOS library project, its main build script is attached. It builds without a problem, then I run
    :podspec
    and then I plug it to Podfile like this:
    # Uncomment the next line to define a global platform for your project
    # platform :ios, '9.0'
    
    target 'AnalyticsDemo' do
      # Comment the next line if you don't want to use dynamic frameworks
      use_frameworks!
    
      # Pods for AnalyticsDemo
      pod "analytics", :path => "../analytics-root/analytics"
    
    end
    When I try to run it in Xcode, it successfully runs several Gradle tasks and then it fails with
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-ios13.2-simulator -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -L/Users/xlebnick/Library/Developer/Xcode/DerivedData/AnalyticsDemo-cvvffnvreniysughwjnehpslgvqy/Build/Products/Debug-iphonesimulator -L/ -L/Users/xlebnick/Library/Developer/Xcode/DerivedData/AnalyticsDemo-cvvffnvreniysughwjnehpslgvqy/Build/Products/Debug-iphonesimulator/Analytics -F/Users/xlebnick/Library/Developer/Xcode/DerivedData/AnalyticsDemo-cvvffnvreniysughwjnehpslgvqy/Build/Products/Debug-iphonesimulator -FPods -FPods/Headers -FPods/Local\ Podspecs -FPods/Target\ Support\ Files -FPods/Target\ Support\ Files/Pods-AnalyticsDemo -FPods/Target\ Support\ Files/analytics -filelist /Users/xlebnick/Library/Developer/Xcode/DerivedData/AnalyticsDemo-cvvffnvreniysughwjnehpslgvqy/Build/Intermediates.noindex/AnalyticsDemo.build/Debug-iphonesimulator/AnalyticsDemo.build/Objects-normal/x86_64/AnalyticsDemo.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/xlebnick/Library/Developer/Xcode/DerivedData/AnalyticsDemo-cvvffnvreniysughwjnehpslgvqy/Build/Intermediates.noindex/AnalyticsDemo.build/Debug-iphonesimulator/AnalyticsDemo.build/Objects-normal/x86_64/AnalyticsDemo_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/xlebnick/Library/Developer/Xcode/DerivedData/AnalyticsDemo-cvvffnvreniysughwjnehpslgvqy/Build/Intermediates.noindex/AnalyticsDemo.build/Debug-iphonesimulator/AnalyticsDemo.build/Objects-normal/x86_64/AnalyticsDemo.swiftmodule -ObjC -lc++ -framework analytics -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/xlebnick/Library/Developer/Xcode/DerivedData/AnalyticsDemo-cvvffnvreniysughwjnehpslgvqy/Build/Intermediates.noindex/AnalyticsDemo.build/Debug-iphonesimulator/AnalyticsDemo.build/AnalyticsDemo.app-Simulated.xcent -framework Pods_AnalyticsDemo -Xlinker -dependency_info -Xlinker /Users/xlebnick/Library/Developer/Xcode/DerivedData/AnalyticsDemo-cvvffnvreniysughwjnehpslgvqy/Build/Intermediates.noindex/AnalyticsDemo.build/Debug-iphonesimulator/AnalyticsDemo.build/Objects-normal/x86_64/AnalyticsDemo_dependency_info.dat -o /Users/xlebnick/Library/Developer/Xcode/DerivedData/AnalyticsDemo-cvvffnvreniysughwjnehpslgvqy/Build/Products/Debug-iphonesimulator/AnalyticsDemo.app/AnalyticsDemo
    
    ld: framework not found analytics
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    My multiplatform module has name
    analytics
    . Why doesn't Xcode see my framework?
    build_gradle_kts.kt
    a
    • 2
    • 5
  • n

    napperley

    02/17/2020, 5:02 AM
    Are there any plans to include documentation on testing Kotlin Native libraries/programs? With Kotlin Native libraries/programs targeting linuxX64 for instance there is no documentation available that covers the following: 1. How to setup testing at the build level (via Gradle) 2. What types of testing are supported by Kotlin Native 3. Which testing libraries/frameworks are available that provide Kotlin Native support 4. Key issues/pitfalls to be aware of when testing a Kotlin Native library/program 5. Basic testing examples covering a Kotlin Native library/program 6. How to test concurrency (covering Workers/Coroutines) in a Kotlin Native library/program
    👍 2
    o
    s
    • 3
    • 6
  • v

    Vlad Balan

    02/17/2020, 11:34 AM
    Hi all, does anybody know when the
    -Xoverride-clang-options
    option is going to be available? I am trying to compile for a custom arm64 target. My
    build.gradle.kts
    contains the following section:
    linuxArm64("arm64"){            
     binaries {
      executable {
       entryPoint = <entry_point>
       freeCompilerArgs += listOf("-Xoverride-clang-options=-target-cpu=cortex-a53")
      }
     }
    }
    and it produces the following warning:
    w: Flag is not supported by this version of the compiler: -Xoverride-clang-options=-target-cpu=cortex-a53
    . Did anybody succeed in compiling for a custom target? Thanks in advance!
    m
    n
    • 3
    • 5
  • j

    Jaxon Du

    02/17/2020, 10:06 PM
    Generated a new project from template > Kotlin > Native | Gradle. Compile and run fine. Then I add a coroutines runBlocking line to the generated sample app:
    package sample
    
    import kotlinx.coroutines.runBlocking
    
    fun hello(): String = "Hello, Kotlin/Native!"
    
    fun main() {
        runBlocking {
            println(hello())
        }
    }
    The error is “unresolved references” to coroutines and runBlocking. Heres the build.gradle file, which just adds the coroutine dependencies. What did I do wrong?
    plugins {
        id 'org.jetbrains.kotlin.multiplatform' version '1.3.61'
    }
    repositories {
        mavenCentral()
    }
    
    kotlin {
        macosX64("macos") {
            binaries {
                executable {
                   entryPoint = 'sample.main'
                    runTask?.args('')
                }
            }
        }
        sourceSets {
            macosMain {
                dependencies {
                    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
                }
            }
            macosTest {
            }
        }
    }
    k
    • 2
    • 3
  • n

    Nikita Khlebushkin

    02/18/2020, 12:43 AM
    Hello, I have yet another question about cocoapods in K/N ☑️ I'm using
    cocoapods
    plugin, specify cocoapods dependency and run
    :analytics:podspec
    (where
    analytics
    is my KMP module) ☑️ podspec is generated and I'm using the project from Podfile ☑️
    import analytics
    works in Xcode ☑️ iOS project with the aforementioned Podfile builds successfully ❌
    import cocoapods.Analytics
    is highlighted in red in Intellij Idea and causes compile errors such as
    Packages cannot be imported
    How do I make the frameworks appear in Kotlin project? Many thanks in advance Configuration files are attached to the thread
    b
    a
    • 3
    • 33
  • m

    madhead

    02/18/2020, 4:07 PM
    Hello! I’m trying to create a Redis module in Kotlin/Native. The module will provide a stack data type:
    class Node(prev: Node?, value: Char)
    class Stack(tail: Node?)
    Redis provides a specific API for memory allocation:
    void *RedisModule_Alloc(size_t bytes)
    . They say it should be preferred over
    malloc
    because “memory allocated with this function is reported in Redis INFO memory, used for keys eviction according to maxmemory settings and in general is taken into account as memory allocated by Redis”. So, I want to use this API to allocate memory for my nodes. My plan was to reinterpret that pointers to my types later. The problem is that I cannot find a way to know the size needed by my claasses, like
    sizeOf<Node>
    . How do I know it?
    a
    n
    • 3
    • 9
  • n

    napperley

    02/19/2020, 10:23 PM
    Does Kotlin Native support Gradle 6.0 ( https://blog.jetbrains.com/kotlin/2020/02/improved-gradle-kts-ide-support/ )?
    k
    u
    • 3
    • 3
  • c

    camkadev

    02/20/2020, 10:15 AM
    is there a way to take
    current time in millis
    ?
    a
    • 2
    • 4
  • c

    camkadev

    02/20/2020, 10:18 AM
    also need example how to
    schedule worker
    that run continuously with fixed rate time (millis) before repeat
    • 1
    • 1
  • j

    Jaxon Du

    02/20/2020, 6:38 PM
    Is there any plan to support iOS Combine framework?
    b
    • 2
    • 2
  • c

    camkadev

    02/21/2020, 10:28 AM
    Could not resolve org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.3
    in Kotlin MPP project, what should i do? Kotlin 1.3.61 Gradle: 6.1.1 Kotlin DSL script
    a
    s
    • 3
    • 13
  • p

    Piet Bronders

    02/22/2020, 2:57 PM
    Could someone please explain me the difference between CPointer and CPointerVar? I have been struggling to understand the difference, but haven't been able to make any headway
    d
    n
    r
    • 4
    • 6
  • s

    Sylvain Patenaude

    02/24/2020, 4:18 PM
    How can I know if a .framework is compiled for iosArm64 or iosX64?
    k
    • 2
    • 1
  • e

    Etienne

    02/24/2020, 7:13 PM
    Anyone here use
    ktor-client-curl
    in their project? I’m running into linker issues, and would like to compare notes / build scripts. (Keeping it short since I posted a long description in the #ktor channel, with no answers for now.)
    j
    • 2
    • 6
  • z

    z3ntu

    02/24/2020, 10:10 PM
    Hi, I have a
    wchar_t *
    in C that I try to convert to a kotlin string with kotlin native. I've used
    .toKStringFromUtf32()
    which works well but it seems that the string has a trailing null byte which is not so pretty 🙂 Is that expected behavior? The documentation states
    Returns: the [kotlin.String] decoded from given zero-terminated UTF-32-encoded C string.
    so my interpretation would be that this is a bug?
    d
    • 2
    • 9
  • s

    Sylvain Patenaude

    02/25/2020, 3:29 PM
    Someone knows why such an error would occur when using Kotlin code natively compiled for iOS? Instances of kotlin.Error, kotlin.RuntimeException and subclasses aren't propagated from Kotlin to Objective-C/Swift. Other exceptions can be propagated as NSError if method has or inherits @Throws annotation. Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared com.company.projectname.package.SomeDataClass@c808c7b8 from other thread
    k
    • 2
    • 5
  • s

    Sander Saelmans

    02/26/2020, 8:55 AM
    Hey all, I'm seeing some weird behaviour when I'm trying to start an iOS application which uses a framework which is compiled using our kotlin native project. The project uses a couple of cinterops on some objectve-c frameworks:
    AppCenter
    ,
    AppCenterCrashes
    ,
    AppCenterAnalytics
    , `KeychainWrapper`; And this seems to work well at this point. However when I try to run the iOS application after interopting this framework: https://github.com/CAAPIM/iOS-MAS-Foundation (which works after modifying the imports in the header files slightly
    @import SomeFramework;
    ->
    #import <SomeFramework/SomeFramework.h>
    ,
    #import <MASFoundation/SomeHeader.h>
    ->
    #import "SomeHeader.h
    ), I get the following error when trying to boot up the application:
    dyld: Library not loaded: /Library/Frameworks/MASFoundation.framework/MASFoundation
    Referenced from: /Users/sandersaelmans/Library/Developer/Xcode/DerivedData/iosApp-dbelcoqoqidymygwatjnbtxoifby/Build/Products/Debug-iphonesimulator/app.framework/app
    Reason: image not found
    The
    .def
    file I'm using looks like this:
    language = Objective-C
    package = com.mas
    headers = MASFoundation.h
    
    compilerOpts = \
        -Isrc/nativeInterop/cinterop/MASFoundation.framework/Headers \
    
    linkerOpts = \
        -Fsrc/nativeInterop/cinterop \
        -framework MASFoundation \
        -framework Foundation \
        -framework UIKit
    Can someone spot what I'm doing wrong here? As my other interops work perfectly...
    a
    s
    k
    • 4
    • 8
  • j

    Jan Stoltman

    02/27/2020, 1:46 PM
    Hey guys, I'm trying to turn this method into K/N, but my cast always fails:
    func isVPNConnected() -> Bool {
        let cfDict = CFNetworkCopySystemProxySettings()
        let nsDict = cfDict!.takeRetainedValue() as NSDictionary
        let keys = nsDict["__SCOPED__"] as! NSDictionary
    
        for key: String in keys.allKeys as! [String] {
            if (key == "tap" || key == "tun" || key == "ppp" || key == "ipsec" || key == "ipsec0") {
                return true
            }
        }
        return false
    }
    Kotlin:
    fun isVPNConnected(): Boolean {
        val cfDict = CFNetworkCopySystemProxySettings()
        val nsDifct = cfDict as? NSDictionary //It fails here
        val keys = nsDifct?.valueForKey("__SCOPED__") as NSDictionary?
    
        return keys?.allKeys?.any { key ->
            key == "tap" || key == "tun" || key == "ppp" || key == "ipsec" || key == "ipsec0" || key == "utun1"
        } ?: false
    }
    Could anybody help me to understand how
    takeRetainedValue
    should be mapped into kotlin?
    a
    r
    • 3
    • 7
  • j

    Joan Colmenero

    02/27/2020, 8:54 PM
    s there a way to use like in Android I'm using log.d("TAG", "message") with NSLog? like specifying the type? Debug, error, information, etc?
    s
    k
    • 3
    • 14
  • a

    Arkadii Ivanov

    03/01/2020, 11:02 PM
    Hello, I have a question. Are there any memory leaks in the following code? This view controller is created and used from Swift.
    fun myViewController(): UIViewController = MyViewControllerImpl()
    
    private class MyViewControllerImpl : UIViewController(nibName = null, bundle = null) {
        private val button = UIButton()
        
        override fun viewDidLoad() {
            super.viewDidLoad()
    
            button.addTarget(target = this, action = sel_registerName("onClick"), forControlEvents = UIControlEventTouchUpInside)
            view.addSubview(button)
        }
        
        @ObjCAction
        private fun onClick() {
        }
    }
    s
    • 2
    • 6
  • m

    Mike

    03/02/2020, 5:44 PM
    Hi, I'm hitting extremely long compile times with kotlin native's compileKotlinJvm task. It takes around 10 minutes to build every time I modify something (I am using a very fast machine). I tried running a profiled build and think incremental build is broken for some reason. Has anyone hit similar issues? https://github.com/JetBrains/kotlin-native/issues/3933
    r
    • 2
    • 2
  • v

    Vlad Balan

    03/03/2020, 4:08 PM
    Hi guys, I came across an unexpected (different that
    kotlin
    ) behavior when running the following example:
    object Test {
    
        private var test: String? = null
    
        fun changeVar() {
            test = "test"
            println("val changed")
        }
    }
    
    fun main(args: Array<String>) {
        Test.changeVar()
    }
    This works in
    Kotlin
    but in
    kotlin-native
    it throws the following exception:
    Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen test.Test@e1d7d8
            at kfun:kotlin.Throwable.<init>(kotlin.String?)kotlin.Throwable (0x22fc57)
            at kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception (0x22a7b5)
            at kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException (0x22a535)
            at kfun:kotlin.native.concurrent.InvalidMutabilityException.<init>(kotlin.String)kotlin.native.concurrent.InvalidMutabilityException (0x232ee5)
            at ThrowInvalidMutabilityException (0x233263)
            at MutationCheck (0x26367e)
            at kfun:cairo.Test.<set-test>#internal (0x242b50)
            at kfun:cairo.Test.changeVar() (0x242bbe)
            at kfun:cairo.main(kotlin.Array<kotlin.String>) (0x242c67)
            at Konan_start (0x242d6b)
            at Init_and_run_start (0x245f7b)
            at __libc_start_main (0x7fb745f461e3)
            at  (0x217029)
            at  ((nil))
    If the
    object Test
    is changed to
    class Test
    :
    class Test {
    
        private var test: String? = null
    
        fun changeVar() {
            test = "test"
            println("val changed")
        }
    }
    
    fun main(args: Array<String>) {
        Test().changeVar()
    }
    then it works as expected. Did somebody encounter this behavior? Is this intended? Is yes, can somebody please explain why? Thanks in advance!
    k
    k
    • 3
    • 4
  • s

    SrSouza

    03/03/2020, 4:21 PM
    Hi guys, can I use a library built in C++ with Kotlin Native? If not, what is the technical problems that make this not possible?
    k
    c
    • 3
    • 4
  • n

    napperley

    03/03/2020, 11:00 PM
    Some ballpark figures on compilation times with Kotlin 1.3.70 on a Kotlin Native project ( https://gitlab.com/napperley/ncurses-hello ) targeting linuxX64, which uses a statically linked C library (ncurses): • Fresh Compile (from a clean build): 21s 648ms (around 10s faster than Kotlin 1.3.61) • Compile From Incremental Change (of one line): 5s 750ms (around 25s faster than Kotlin 1.3.61) Compilation was done on a laptop (ThinkPad T480) that uses a Intel i5-8250U 8th Gen (Kaby Lake) CPU (4 cores, 8 hyper threads), and a Samsung 860 Evo SSD.
    👍 13
    d
    s
    • 3
    • 8
  • a

    asad.awadia

    03/04/2020, 1:11 AM
    What kind of libraries are you using for kotlin native? specifically for DB and File access, and HTTP Clients?
    s
    k
    +2
    • 5
    • 4
Powered by Linen
Title
a

asad.awadia

03/04/2020, 1:11 AM
What kind of libraries are you using for kotlin native? specifically for DB and File access, and HTTP Clients?
s

Sean Keane

03/04/2020, 1:25 AM
Using it for iOS,
Ktor : Netowrking
Multiplatform Settings: Persistance
k

kpgalligan

03/04/2020, 1:56 AM
Sqldelight for db
n

napperley

03/04/2020, 3:43 AM
• Ktor Client - HTTP client (with the Linux targets only linuxX64 is supported) • Posix (available on all the Linux targets) - Covers general I/O including files (Note: it is a C library) There is KotlinX IO which covers general I/O, but doesn't support files yet.
t

Thanhhai08sk

03/04/2020, 7:06 AM
Objectbox for each platforms for DB
View count: 2