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

    Timothy Wong

    05/30/2019, 8:55 AM
    Trying to compile for raspberry pi while on macintosh is still giving me a couple of issues, (I thought cross-compilation was possible!)
    Target 'native' for platform linux_arm32_hfp is ignored during build on this macos_x64 machine. You can build it with a linux_x64 host.
    o
    • 2
    • 1
  • d

    Daniel Baird

    05/30/2019, 10:32 PM
    Hi folks, I'm currently trying to create a UUID on windows and i'm running into some undefined reference issues. `undefined reference to
    __imp_UuidCreate'
    This method exists in platform.windows. I'm assuming i'm just missing a linker flag, but I'm not sure how to determine what linker flag I need. I have already added
    -luuid
    . Any thoughts?
    d
    d
    • 3
    • 5
  • j

    Josh Feinberg

    05/31/2019, 8:51 PM
    Is there a trick to getting the FatFrameworkTask working? Running AS with Kotlin 1.3.31.
    build.gradle
    is in groovy
    unable to resolve class org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
       @ line 2, column 1.
         import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
    i
    • 2
    • 13
  • r

    russhwolf

    06/01/2019, 4:33 AM
    Is the code coverage functionality described in https://github.com/JetBrains/kotlin-native/blob/master/CODE_COVERAGE.md not yet available in 1.3.31? When I try to run the coverage sample I see
    w: Flag is not supported by this version of the compiler: -Xlibrary-to-cover=...
    and the llvm commands fail because the
    profraw
    file is never generated.
    s
    • 2
    • 1
  • r

    ribesg

    06/03/2019, 8:50 AM
    Anyone got this problem already?
    > Task :linkTestDebugExecutableIosSim
    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
    Occurred after adding some imports for
    platform.UIKit.<stuff>
    in a file
    s
    • 2
    • 11
  • c

    cbruegg

    06/03/2019, 7:10 PM
    Apple just announced a new UI toolkit, called "SwiftUI". It's built in Swift apparently. Can I use this from Kotlin/Native?
    j
    l
    s
    • 4
    • 4
  • l

    louiscad

    06/03/2019, 7:23 PM
    I think we can't just yet, but given Swift 5 now has a stable ABI (which was probably required for SwiftUI), and the fact that SwiftUI seems to be already designed further than Compose (I didn't hear them mention preview), it's very likely Kotlin/Native interop with Swift will see its priority be increased.
    👍 1
    b
    k
    +4
    • 7
    • 50
  • d

    darkmoon_uk

    06/03/2019, 8:44 PM
    Screams were heard briefly... I hope it's okay... 🤔
    🍾 2
    😂 2
    s
    • 2
    • 1
  • p

    pyryjook

    06/04/2019, 6:11 AM
    Hey! I was playing with the Kotlin/Native to create a CLI app for MacOs and along the way I encountered this issue (CoreLocation package definition missing): https://github.com/JetBrains/kotlin-native/issues/3041 As it was suggested in the issue I’m now defining the cinterop in my
    build.gradle.kts
    -file as follows:
    macosX64 {
            val lunchfinderMain by compilations.creating {
                val coreLocation by cinterops.creating {
                    defFile(project.file("CoreLocation.def"))
                    packageName("platform.CoreLocation")
                }
            }
        }
    The file
    CoreLocation.def
    is now located in the (default) path
    src/nativeInterop/cinterop/CoreLocation.def
    When I run the build I get the same error as described in the ticket (the imported
    platform.CoreLocation
    package not found). Any suggestions on what might be wrong with my Gradle config? Thanks already in advance!
    d
    • 2
    • 8
  • s

    spierce7

    06/04/2019, 3:45 PM
    I missed the announcement yesterday, but will SwiftUI be usable from ObjC, and thus from Kotlin/native?
    k
    s
    • 3
    • 3
  • j

    Josh Feinberg

    06/04/2019, 9:46 PM
    is there a reason that the fatframework task for cocoapods doesn't provide a way to generate a fat framework including x86
    b
    j
    +2
    • 5
    • 11
  • d

    Daniel Hauschildt

    06/05/2019, 6:19 AM
    I have a question concerning BitCode on iOS. As far as I know, K/N is not able to embed bitcode which does make kotlin/native somewhat usuable for us (currently). However, I was wondering why or if there is a C / obj-c output target which I can just feed in to the Apple LLVM compiler. Somehwat like Kotlin/js which transpiles to JavaScript and is the JIT compiled in the browser? Even bigger brands like UNITY use this way to compile C# on iOS.
    s
    l
    k
    • 4
    • 23
  • a

    andreasmattsson

    06/05/2019, 7:08 AM
    Hi! Anyone know if it's possible to, with the cocoapods gradle plugin, define dependencies on pods based on local paths rather than by Pod version? (my specific use case is for flutter where the pod is stored locally in a
    $flutterProjectDir/.iOS/Flutter/engine/
    dir?
    i
    • 2
    • 2
  • p

    pyryjook

    06/05/2019, 7:57 AM
    I opened the both of the example projects bundled with the CLion Kotlin/Native plugin (on Mac), “Hello World” and “CSVParser”. Both resulted with unresolved references in the IDE. For example even the
    println
    is an unresolved reference in the Hello World example. Any suggestions on what would fix the problem?
    ✔️ 1
    k
    • 2
    • 7
  • t

    Thomas

    06/05/2019, 9:54 AM
    I cannot get Kotlin native working with the new SwiftUI. The app works fine in the simulator, but if I want to see a preview in Xcode I get this error:
    Terminating app due to uncaught exception 'NSGenericException', reason: 'Only one Kotlin framework can be loaded currently'
    terminating with uncaught exception of type NSException
    g
    s
    s
    • 4
    • 11
  • t

    Thomas

    06/05/2019, 1:54 PM
    Is it possible to make a Swift struct implement a Kotlin interface? For example in Swift:
    struct MyStruct : KotlinInterface {
    }
    And in Kotlin:
    interface KotlinInterface {
        ...
    }
    I tried this but it gives the following error:
    Non-class type 'MyStruct' cannot conform to class protocol 'KotlinInterface'
    s
    k
    s
    • 4
    • 9
  • r

    ribesg

    06/06/2019, 1:30 PM
    What kind of compilation time optimization can we expect in the future? I’m currently sitting at 7min build for an iOS Framework. I can go down to 3min when building only the simulator architecture, but it’s still kinda long when something does not work and I have to try and do some die and retry to find the issue
    🙏 11
    ➕ 6
    o
    n
    • 3
    • 2
  • m

    m

    06/06/2019, 5:04 PM
    Hi. I have
    __attribute__((objc_subclassing_restricted))
    __attribute__((swift_name("A")))
    @interface Lib_babylon_clientA : KotlinBase
    - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
    + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
    - (void)b __attribute__((swift_name("b()")));
    @end;
    in .h file of generated .framework file. What could be the reason of
    Type 'A' has no member 'b'
    Swift compilation error for
    A().b()
    ?
    m
    • 2
    • 2
  • z

    Zh Efimenko

    06/06/2019, 9:23 PM
    Hi everyone. help me pls. How can I get resources in kotlin-native? I cannot use this example:
    UtilsTests::class..getResource("/source.pst")
    How can I get classpath?
    k
    d
    a
    • 4
    • 10
  • j

    jimn

    06/07/2019, 8:15 AM
    so, i started a multiplatform project in IDEA, then i wanted to add kotlinx-io. i think i have spent hours trying permutations of dependencies in gradle but the only thing that seems to work is using maven with a jdk project
    o
    d
    • 3
    • 5
  • e

    elizarov

    06/07/2019, 9:21 PM
    It will be in
    kotlinx-io
    . It is just not ready yet.
    j
    • 2
    • 21
  • p

    pyryjook

    06/08/2019, 6:39 AM
    Hey! I’m currently learning to write Kotlin/Native code that uses Apple framework packages. Most of the cases are clear, but this particular problem troubles me. How to write this piece of code, especially the
    extension
    part in Kotlin.
    lass LocationService: NSObject {
        
        let locationManager: CLLocationManager
        init(locationManager: CLLocationManager = CLLocationManager()) {
        	self.locationManager = locationManager
        	super.init()
        	self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
        	self.locationManager.delegate = self
        }
        func getCurrentLocation() {
        	self.locationManager.requestLocation()
        	self.locationManager.requestWhenInUseAuthorization()
        }
    }
    
    extension LocationService: CLLocationManagerDelegate {
        
        func locationManager(_ manager: CLLocationManager, didUpdateLocations locations:[CLLocation]) {
        	guard let location = locations.first else { return }
        	print("The location is: \(location)")
        }
        func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
        	print("Error: \(error)")
        }
    }
    I do know that the original
    CLLocationManagerDelegate
    protocol is actually interface with a name
    CLLocationManagerDelegateProtocol
    on the Kotlin/Native side. I tried googling, but did not find any examples on how to approach Swift extensions in Kotlin/Native. Any help would be highly appreciated, thanks!
    g
    s
    • 3
    • 5
  • j

    jeremy

    06/08/2019, 11:44 PM
    Is runblocking not available in KN?
    b
    f
    • 3
    • 8
  • j

    jeremy

    06/09/2019, 2:52 PM
    Is there support in IntelliJ for executing tests in IDE? They result in "test events not received". Running command line works
    k
    d
    +2
    • 5
    • 10
  • n

    napperley

    06/10/2019, 1:35 AM
    Is it possible to specify dependency resolution with C libs at the Gradle build file level (eg have the glinegraph def file depend on the gtk3 def file)?
    d
    s
    • 3
    • 30
  • z

    Zh Efimenko

    06/10/2019, 7:18 AM
    Hi everyone. I have a problem with a enum, which has own method:
    enum class PropertyDataType{
        P_TYP_INTEGER_16() {
            override fun getData(byteArray: ByteArray): Int {
                 ...
            }
        }
    }
    kotlin compile throw exception:
    e: Compilation failed: Could not find serialized descriptor for index: -7412938954638445921 com.tullynore.pst.domain.dictionary,PropertyDataType.P_TYP_INTEGER_16,<init>
    
     * Source files: FolderTests.kt, MessageTests.kt, UtilsTests.kt
     * Compiler version info: Konan: 1.2.1 / Kotlin: 1.3.31
     * Output kind: PROGRAM
    
    e: java.lang.IllegalStateException: Could not find serialized descriptor for index: -7412938954638445921 com.tullynore.pst.domain.dictionary,PropertyDataType.P_TYP_INTEGER_16,<init>
    Maybe someone already had such an exception? Who can help me?
    s
    • 2
    • 2
  • r

    Rohan Maity

    06/10/2019, 1:23 PM
    I downloaded kotlin-native compiler. And added
    bin
    folder to PATH. But when try to run
    hello.kt
    by
    kotlinc-native hello.kt
    . I get
    exception: java.nio.charset.MalformedInputException: Input length = 1
            at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
            at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
            at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
            at java.io.InputStreamReader.read(InputStreamReader.java:184)
            at java.io.BufferedReader.read1(BufferedReader.java:210)
            at java.io.BufferedReader.read(BufferedReader.java:286)
            at java.io.Reader.read(Reader.java:140)
            at java.util.Properties$LineReader.readLine(Properties.java:434)
            at java.util.Properties.load0(Properties.java:353)
            at java.util.Properties.load(Properties.java:317)
            at org.jetbrains.kotlin.konan.properties.PropertiesKt.loadProperties(Properties.kt:28)
            at org.jetbrains.kotlin.konan.target.Distribution$properties$2.invoke(Distribution.kt:67)
            at org.jetbrains.kotlin.konan.target.Distribution$properties$2.invoke(Distribution.kt:24)
            at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
            at org.jetbrains.kotlin.konan.target.Distribution.getProperties(Distribution.kt)
            at org.jetbrains.kotlin.konan.target.PlatformManager.<init>(Platform.kt:36)
            at org.jetbrains.kotlin.konan.target.PlatformManager.<init>(Platform.kt:32)
            at org.jetbrains.kotlin.backend.konan.KonanConfig.<init>(KonanConfig.kt:36)
            at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:59)
            at org.jetbrains.kotlin.cli.bc.K2Native.doExecute(K2Native.kt:35)
            at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:84)
            at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:42)
            at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:103)
            at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:81)
            at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:49)
            at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:214)
            at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:206)
            at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:217)
            at org.jetbrains.kotlin.cli.bc.K2Native$Companion$main$1.invoke(K2Native.kt:208)
            at org.jetbrains.kotlin.konan.util.UtilKt.profileIf(Util.kt:39)
            at org.jetbrains.kotlin.konan.util.UtilKt.profile(Util.kt:33)
            at org.jetbrains.kotlin.cli.bc.K2Native$Companion.main(K2Native.kt:210)
            at org.jetbrains.kotlin.cli.bc.K2NativeKt.main(K2Native.kt:296)
            at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:16)
    And this is my hello.kt file
    fun main(){
            println("hello native")
    }
    s
    o
    • 3
    • 19
  • k

    Kruger Brent

    06/10/2019, 3:42 PM
    Hello guys, I am trying to use a C-library in my Kotlin based app. I have gone through the official documentation, but I didn't find a resource that explains how to add a C-library as dependency to an Android Project and can be used in the SharedCode Kotlin module! Any help appreciated.
    s
    f
    k
    • 4
    • 16
  • f

    FalseHonesty

    06/10/2019, 4:26 PM
    I've got a question on actually porting C code into Kotlin code.
    struct nk_context ctx;
    nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);
    This is some C code for the library I'm trying to use (Nuklear). How would I convert that to Kotlin interop code?
    o
    • 2
    • 1
  • m

    Marc Knaup

    06/11/2019, 4:47 PM
    Is it actually good practice that all classes (also in common code) self-freeze if they're known to be immutable? Let's say I make a multi-platform date/time library where everything is immutable. Should I freeze all class instances in their initializer?
    b
    • 2
    • 1
Powered by Linen
Title
m

Marc Knaup

06/11/2019, 4:47 PM
Is it actually good practice that all classes (also in common code) self-freeze if they're known to be immutable? Let's say I make a multi-platform date/time library where everything is immutable. Should I freeze all class instances in their initializer?
b

basher

06/11/2019, 6:11 PM
we've been doing this in our codebase. working alright so far!
👍 1
View count: 3