Skip to content

Configuration

Both plugins are configured through a swiftpm { } block in build.gradle.kts.

Type: DirectoryPropertyRequired

Path to the directory containing Package.swift.

swiftpm {
path = file("../MySwiftPackage")
}

Type: Property<String>Required

Name of the SPM product to build. Must be a dynamic library product defined in Package.swift.

swiftpm {
product = "MySwiftPackage"
}

Type: ListProperty<TargetPlatform> — Default: host OS platform

List of target platforms to build for. If not set, the plugin targets the current host OS automatically.

swiftpm {
platforms = listOf(
TargetPlatform.macOS(),
TargetPlatform.Linux()
)
}

See TargetPlatform below for available types and their options.

Type: Property<Int> — Default: 11

Java language compatibility level for the generated bridging classes. Set to match your project’s sourceCompatibility.

swiftpm {
javaVersion = 8
}

On Android, if minSdk is below API 33, the plugin overrides this to 8 automatically.

Type: RegularFileProperty — Default: ~/Library/Developer/Scade/Toolchains/scd/bin/scd

Path to the scd binary. Only needed if scd is installed in a non-standard location.

swiftpm {
scd = file("/usr/local/bin/scd")
}

Type: Property<Boolean> — Default: false

When true, the plugin checks for a newer version of scd before each build and updates it if one is available.

swiftpm {
scdAutoUpdate = true
}

Type: ListProperty<String> — Default: []

Additional command-line arguments passed directly to scd archive. Use this to pass flags not exposed by the DSL.

swiftpm {
scdOptions = listOf("--verbose")
}

A DSL block for specifying native libraries to link into the Swift build. Resolved artifacts are passed to scd via -l flags.

swiftpm {
dependencies {
project(":sqlite") // another Gradle project
link("com.example:mylib:1.0") // Maven artifact
}
}

TargetPlatform is a sealed interface with four implementations.

TargetPlatform.macOS(
toolchain: File? = null // optional: path to a custom Swift toolchain
)
TargetPlatform.Android(
archs: List<String> = listOf(), // ABIs to build; defaults to arm64-v8a, x86_64
toolchain: File? = null // optional: path to a custom Swift for Android toolchain
)

Supported archs values: arm64-v8a, armeabi-v7a, x86_64, x86.

TargetPlatform.Linux()
TargetPlatform.Windows()