Skip to content

Overview

The SPM Gradle Plugin integrates Swift Package Manager builds into Gradle. It handles building your Swift package as a native dynamic library, generating Java/Kotlin bridging classes, and wiring the outputs into your Gradle project so they are available at compile time and at runtime.

The plugin uses scd as its Swift build backend.

The SPM Gradle Plugin ships as two complementary plugins:

io.scade.gradle.plugins.swiftpm — for standard Java and Kotlin Gradle projects. Adds a single assembleSwiftPackage task and integrates the build output and generated bridging sources into the main source set.

io.scade.gradle.plugins.android.swiftpm — for Android projects. Extends the base plugin with per-variant task registration, automatic Android SDK/NDK path resolution, connected-device ABI detection, and Android ViewModel generation for @Observable types.

Both plugins are configured through the same swiftpm { } DSL block.

  1. Resolves the scd binary (and optionally updates it)
  2. Runs swift package plugin generate-java-bridging to generate Kotlin/Java proxy classes from @jvm-annotated Swift types
  3. Runs scd archive to build the Swift package as a dynamic library for the target platform
  4. Adds the generated sources and the native library to the Gradle project so they are picked up by compilation and packaging

See Getting Started to apply the plugin and run your first build.