BT

InfoQ Homepage News Kotlin 1.3.30 Brings Kotlin/Native and KAPT Improvements, and More

Kotlin 1.3.30 Brings Kotlin/Native and KAPT Improvements, and More

This item in japanese

Bookmarks

JetBrains has released Kotlin 1.3.30. This version is mainly a new bug fix and tooling update for Kotlin 1.3. Kotlin 1.3.30 brings Kotlin/Native and KAPT improvements, support for more operations for unsigned types and arrays, debugging improvements on IntelliJ IDEA, and more.

Kotlin/Native now supports Windows 32 bit target (mingw_x86). Furthermore, macOS and Windows users can cross-compile Kotlin/Native programs to Linux x86-64, arm32, Android and Raspberry PI devices.

Apple platforms have received a series of improvements from Kotlin/Native. Regarding exceptions, developers can find unhandled exceptions logged in the iOS crash logs, and exception backtraces now contain symbolic information on iOS and macOS when in debug mode.

Apple developers can also generate static frameworks using -Xstatic-framework command line parameter, or the following Gradle script for a multiplatform project:

kotlin {
    macosX64 {
        binaries {
            framework {
                isStatic = true
            }
        }
    }
}

Apple developers can also benefit from an experimental feature that provides integration with CocoaPods by using a Gradle plugin. This feature turns a Kotlin/Native project into a .podfile dependency, which can be included into a Podfile. Thus, developers should have the same experience as using Swift or Objective-C pods with XCode. Furthermore, it is also possible to import CocoaPods dependencies into a Kotlin/Native project. The gradle plugin responsible for that feature handles all necessary configuration to import a framework into a Kotlin/Native project.

// Apply plugins.
plugins {
    id("org.jetbrains.kotlin.multiplatform") version "1.3.30"
    /// the new plugin for CocoaPods support
    id("org.jetbrains.kotlin.native.cocoapods") version "1.3.30"
}

// CocoaPods requires the podspec to have a version.
version = "1.0"

kotlin {
    cocoapods {
        summary = "a Kotlin/Native module"
        homepage = "homepage"

        pod("AFNetworking", "~> 3.2.0")
    }
}

The following steps are necessary to import a Kotlin/Native module in an existing Xcode project:

  • Make sure CocoaPods is installed
  • Configure a gradle project: apply the org.jetbrains.kotlin.native.cocoapods plugin, add and configure the targets, and specify the required podspec fields
  • Run the podspec task. The podspec file described above will be generated
  • Add a reference to the generated podspec in a Podfile of the Xcode project
    target 'my-ios-app' do
        pod 'my_kotlin_library', :path => 'path/to/my-kotlin-library'
    end
    
  • Run pod install for the Xcode project.

Annotation processors (JSR 269) that already are supported in Kotlin by KAPT compiler plugin have been improved. KAPT now supports an experimental feature that enables incremental annotation processors; developers who want to try it should add the following to the gradle.properties:

kapt.incremental.apt=true

Another interesting feature regarding KAPT is Compile Avoidance, which skips annotation processing when only method bodies are changed. Compile Avoidance is possible only when all KAPT dependencies are declared explicitly in annotation processing classpath. To turn on Compile Avoidance, add the following to the gradle.properties:

kapt.include.compile.classpath=false

Kotlin 1.3.30 brings support for more operations for unsigned types and arrays of unsigned types:


fun main() {
    val u1 = 2_147_483_649u
    val u2 = 4_000_000_000u
    println(u1.toDouble())
    println(minOf(u1, u2))

    val array: UIntArray = uintArrayOf(u1, u2)
    println(array.max())
    println(array.all { it > Int.MAX_VALUE.toUInt() })
}

Since unsigned arrays implement Collection ( e.g. Collection<UInt> for UIntArray), developers can now use operations like filter and map.

IntelliJ IDEA support for Kotlin 1.3.30 has been improved. Now it is possible to debug coroutines easier; a separate "Async stack trace" shows the variables stored at the time of suspension.

Another debugging improvement on IntelliJ IDEA is the "Kotlin" mode, which enables developers see the variables by Kotlin name, rather than auxiliary JVM names:


(image taken from https://blog.jetbrains.com)

Other features and bug fixes that are important to note regarding IntelliJ IDEA include:

  • Added intention to replace isEmpty/isNotEmpty method negation. For example, !isEmpty() -> isNotEmpty() and !isNotEmpty() -> isEmpty()
  • Added inspection + quickfix for replacing Collection.count() with .size. For example, listOf(1, 2).count() -> listOf(1, 2).size
  • Added inspection to replace Java 8 Map.forEach with Kotlin's forEach
  • Added warning about redundant requireNotNull and checkNotNull usages
  • Fix incorrect KT elvis expression debugger evaluation
  • Support Multiline TODO comments.

The complete list of changes is available in the changelog. To update to Kotlin 1.3.30, IntelliJ IDEA and Android Studio, users should go in Tools>Kotlin>Configure Kotlin Plugin Updates, and click the "Check for updates now"; Eclipse users should install the plugin using Marketplace; or to update from maven, Gradle and npm, users should use 1.3.30 as the version number for the compiler and the standard library. Additional documentation is available here.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.