DEV Community

Cover image for Swift Klib v0.2.0 is out
Evgeny Khokhlov
Evgeny Khokhlov

Posted on

Swift Klib v0.2.0 is out

Swift Klib Gradle Plugin v0.2.0 is released.

GitHub logo ttypic / swift-klib-plugin

Gradle Plugin for injecting Swift code into Kotlin Multiplatform Mobile shared module

Swift Klib library logo

Swift Klib Gradle Plugin

badge-ios badge-mac badge-tvos badge-watchos

This gradle plugin provides easy way to include your Swift source files in your Kotlin Multiplatform Mobile shared module and access them in Kotlin via cinterop for iOS targets. It is useful for:

  • Accessing Swift-only libraries (e.g. CryptoKit)
  • Creating a Kotlin-Friendly Swift API
  • Learning how Swift <-> Kotlin interoperability works

Note: Plugin has been tested on Gradle 7.5+, Xcode 15+

Installation

Using the plugins DSL:

plugins {
    id("io.github.ttypic.swiftklib") version "0.5.1"
}
Enter fullscreen mode Exit fullscreen mode

Using legacy plugin application:

buildscript {
  repositories {
    maven {
      url = uri("https://plugins.gradle.org/m2/")
    }
  }
  dependencies {
    classpath("io.github.ttypic:plugin:0.5.1")
  }
}

apply(plugin = "io.github.ttypic.swiftklib")
Enter fullscreen mode Exit fullscreen mode

Usage

Plugin works together with Kotlin Multiplatform plugin.

Prepare Swift code

Place your Swift files inside your project in separate folder (e.g. native/HelloSwift).

Make sure that Swift API you want…

This gradle plugin provides easy way to include your Swift source files in your Kotlin Multiplatform Mobile
shared module and access them in Kotlin via cinterop for iOS targets. It is useful for:

  • Accessing Swift-only libraries (e.g. CryptoKit)
  • Creating a Kotlin-Friendly Swift API
  • Learning how Swift <-> Kotlin interoperability works

This release contains:

  • Fix: add a step to clean old build files in the build directory
  • Light refactoring of source code

Top comments (0)