Kotlin/Native binary options
This page lists helpful Kotlin/Native binary options that you can use to configure Kotlin/Native final binaries and the ways to set up binary options in your project.
How to enable
You can enable binary options in the gradle.properties
file, your build file, or pass them as compiler arguments.
In Gradle properties
You can set binary options in your project's gradle.properties
file using the kotlin.native.binary
property. For example:
In your build file
You can set binary options for your project in your build.gradle.kts
file:
For specific binaries using the
binaryOption
attribute. For example:kotlin { iosArm64 { binaries { framework { binaryOption("smallBinary", "true") } } } }As
-Xbinary=$option=$value
compiler options in thefreeCompilerArgs
attribute. For example:kotlin { iosArm64 { compilations.configureEach { compilerOptions.configure { freeCompilerArgs.add("-Xbinary=smallBinary=true") } } } }
In the command-line compiler
You can pass binary options as -Xbinary=$option=$value
directly in the command line when executing the Kotlin/Native compiler. For example:
Binary options
Option | Values | Description | Status |
---|---|---|---|
| Decreases the binary size for release binaries. | Experimental since 2.2.20 | |
| Enables stack canaries: use | Available since 2.2.20 | |
| Controls paging of allocations (buffering). When | Experimental since 2.2.0 | |
| Controls support for Latin-1-encoded strings to reduce application binary size and adjust memory consumption. | Experimental since 2.2.0 | |
| Controls memory tagging, necessary for memory consumption tracking on Apple platforms. Values | Available since 2.2.0 | |
|
| Controls the default allocator. When | Available since 2.2.0 |
| Controls garbage collection behavior:
|
| |
| Disables parallelization of the mark phase in garbage collection. May increase GC pause time on large heaps. | Available since 1.7.20 | |
| Enables tracking GC-related pauses in the project for debugging in Xcode Instruments. | Available since 2.0.20 | |
|
| Configures inlining optimization pass in the Kotlin IR compiler, which comes before the actual code generation phase (disabled by default). The recommended number of tokens (code units parsed by the compiler) is 40. | Experimental since 2.1.20 |
| Controls deinitialization of Swift/Objective-C objects. When | Available since 1.9.0 | |
| Controls timer-based invocation of the garbage collector when the application runs in the background. When | Experimental since 1.7.20 | |
|
| Sets bundle ID ( | Available since 1.7.20 |
|
| Sets short bundle version ( | Available since 1.7.20 |
|
| Sets bundle version ( | Available since 1.7.20 |
|
| Adds file locations and line numbers to exception stack traces.
| Experimental since 1.6.20 |
What's next
Learn how to build final native binaries.