Configuration
Both plugins are configured through a swiftpm { } block in build.gradle.kts.
Properties
Section titled “Properties”Type: DirectoryProperty — Required
Path to the directory containing Package.swift.
swiftpm { path = file("../MySwiftPackage")}product
Section titled “product”Type: Property<String> — Required
Name of the SPM product to build. Must be a dynamic library product defined in Package.swift.
swiftpm { product = "MySwiftPackage"}platforms
Section titled “platforms”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.
javaVersion
Section titled “javaVersion”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")}scdAutoUpdate
Section titled “scdAutoUpdate”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}scdOptions
Section titled “scdOptions”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")}dependencies
Section titled “dependencies”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
Section titled “TargetPlatform”TargetPlatform is a sealed interface with four implementations.
TargetPlatform.macOS
Section titled “TargetPlatform.macOS”TargetPlatform.macOS( toolchain: File? = null // optional: path to a custom Swift toolchain)TargetPlatform.Android
Section titled “TargetPlatform.Android”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
Section titled “TargetPlatform.Linux”TargetPlatform.Linux()TargetPlatform.Windows
Section titled “TargetPlatform.Windows”TargetPlatform.Windows()