Kotlin/Native is a technology for compiling Kotlin to native binaries that run without any VM. It comprises a LLVM-based backend for the Kotlin compiler and a native implementation of the Kotlin runtime library.
Questions tagged [kotlin-native]
361 questions
                    
                    21
                    
            votes
                
                5 answers
            
        Kotlin Native how to convert ByteArray to String?
I was playing with the kotlin-native samples.
I wonder how I could get String from pinned ByteArray. Just want to print it in the console.
         
    
    
        Stepango
        
- 4,721
- 3
- 31
- 44
                    20
                    
            votes
                
                1 answer
            
        What's the difference between Kotlin JVM and Kotlin Native?
So I know Kotlin Native is obviously Native and Kotlin JVM isn't but is the code between Kotlin JVM and Kotlin Native:
1. Different Compiler and Different Code
2. Different Compiler and Similar Code
3. Different Compiler and Same Code
4. None of the…
         
    
    
        SmushyTaco
        
- 1,421
- 2
- 16
- 32
                    19
                    
            votes
                
                3 answers
            
        withTimeout function gives IllegalStateException: There is no event loop. Use runBlocking { ... } to start one. in Kotlin Multiplatform iOS client
Update:
It works if I first execute a coroutine without timeout and then withTimeout. But If I execute a coroutine withTimeout first then it gives me an error. same goes for Async as well.
I am creating a demo kotlin multiplatform application where…
         
    
    
        Paresh Dudhat
        
- 1,166
- 1
- 14
- 28
                    18
                    
            votes
                
                5 answers
            
        Kotlin native equivalent of Retrofit
With Kotlin native giving us the promise of cross platform development and native executables, is there an equivalent of the Java lib Retrofit for Kotlin Native?  IOW is there a pure Kotlin networking library that makes creating http client code…
         
    
    
        Patrick Jackson
        
- 18,766
- 22
- 81
- 141
                    15
                    
            votes
                
                1 answer
            
        How to convert Kotlin ByteArray to NsData and viceversa
Fighting with a Kotlin Multiplatform project I have ended with the problem of needing to work with NsData on my iOS platform from the sharedModule working with Kotlin Native.
Because of this, I need to transform objectiveC NsData to Kotlin ByteArray…
         
    
    
        Francisco Durdin Garcia
        
- 12,540
- 9
- 53
- 95
                    14
                    
            votes
                
                1 answer
            
        How Kotlin/Native garbage collector works in C?
I'm found some explanation of Kotlin/Native memory management model in JetBrains FAQ. 
A: Kotlin/Native provides an automated memory management scheme,
  similar to what Java or Swift provides. The current implementation
  includes an automated…
         
    
    
        Valeriy K.
        
- 2,616
- 1
- 30
- 53
                    14
                    
            votes
                
                1 answer
            
        How is Kotlin specifically compiled?
I'm trying to understand the journey Kotlin source code goes through when it is compiled. The documentation states
When targeting the JVM, Kotlin produces Java compatible bytecode. When targeting JavaScript, Kotlin transpiles to ES5.1 and generates…
         
    
    
        Alessandro Lorusso
        
- 327
- 2
- 16
                    12
                    
            votes
                
                2 answers
            
        Kotlin Multiplatform Mobile: How to handle errors (network, db, etc.) in iOS?
I have this function that makes a network request and writes results to SQLDelight database:
@Throws(Exception::class)
suspend fun updateData()
In iOS project in Xcode I see that this function is translated into a function with completionHandler of…
         
    
    
        Marat
        
- 6,142
- 6
- 39
- 67
                    12
                    
            votes
                
                1 answer
            
        How is Kotlin code compiled into native code?
The official Kotlin/Native documentation states that Kotlin/Native
.. is an LLVM based backend for the Kotlin compiler.
As far as I understand:
The Kotlin compiler (kotlinc) produces .class files (with Java bytecode) from your Kotlin source…
         
    
    
        Andreas
        
- 123
- 1
- 6
                    12
                    
            votes
                
                1 answer
            
        Does kotlin-native have destructors?
In kotlin native there is memScoped function that automatically free allocated memory when control is going out of scope.
Is there something like destructors for local objects?
         
    
    
        Vladimir Berezkin
        
- 3,580
- 4
- 27
- 33
                    11
                    
            votes
                
                4 answers
            
        Kotlin-native execute command and get the output
I'd like to know if there's a way in kotlin native to call a command via posix and receive it's terminal output. For example, I'd like to get the "git diff" command working without having to create a temporary file, write output to it and then read…
         
    
    
        MG lolenstine
        
- 919
- 1
- 11
- 32
                    11
                    
            votes
                
                2 answers
            
        How to determine build type in kotlin-multiplatform project
I’m working on a multiplaform project, iOS and JVM (I’m not targeting Android directly). Depending on the build type (debug or release) I want to configure the logging level (i.e. to print only errors in release). Since there is no a BuildConfig…
         
    
    
        Diego Palomar
        
- 6,958
- 2
- 31
- 42
                    11
                    
            votes
                
                1 answer
            
        Kotlin Native equivalent of System.exit(-1)
In the following Kotlin/JVM program System.exit(-1) stops the execution of the program with an error exit code:
fun main(args: Array) {
    if (args.size < 2) {
        println("too few args!")
        System.exit(-1)
    }
   … 
         
    
    
        Nate Vaughan
        
- 3,471
- 4
- 29
- 47
                    10
                    
            votes
                
                3 answers
            
        File IO with Kotlin multiplatform
I would like to do some basic filesystem operations on mingwX64 Windows (and possibly other platforms): open, close, read, rename, get metadata, list files in a directory.
I have found one project that promises to implement this functionality:…
         
    
    
        Ford O.
        
- 1,394
- 8
- 25
                    10
                    
            votes
                
                0 answers
            
        expected has no actual declaration for common JVM in project without JVM preset
I want to create a simple multiplatform app for android and IOS this is my common module config
kotlin{
    sourceSets{
        commonMain{
            dependencies{
                implementation "org.jetbrains.kotlin:kotlin-stdlib-common:1.3.61"
 …
         
    
    
        max
        
- 5,963
- 12
- 49
- 80