Android Guide
Gradle Plugins Guide
Section titled “Gradle Plugins Guide”The plugin provides tasks to build Swift packages, generate Java bridgings, and assemble final Android products.
Use of latest version
Section titled “Use of latest version”Make sure to use the latest version. Some screenshots or examples may be outdated and not updated every time. The latest version of the Gradle and Swift4j plugins can be found here:
NOTE: you can also consider to always use the latest version by using latest.release instead of a version in the plugins configuration section. For more details see an example in the Applying plugin section.
Getting Started
Section titled “Getting Started”Dependencies
Section titled “Dependencies”Xcode version should be chosen such that the version of the Swift Toolchain included within Xcode matches the version of the Swift for Androind Toolchain. All releases of the Swift for Android Toolchain can be found at Swift for Android
To check the Swift version you can run swiftc -version. To choose between Xcode versions you can use xcode-select.
Depending on the installed Swift versions, the plugin will download automatically the most suitable version of the Swift for Android Toolchain.
Applying plugin
Section titled “Applying plugin”To apply the plugin, add the plugin’s id into the plugins block in the build file build.gradle.kts that resides in the app directory of the project:
plugins { id("io.scade.gradle.plugins.android.swiftpm") version "latest.release"}Plugins configuration
Section titled “Plugins configuration”Add the following configuration section to the build file build.gradle.kts:
swiftpm { // Full Path to the folder containing Package.swift path = file("<PACKAGE LOCATION>") // Name of the package's product product = "<PRODUCT NAME>"
// OPTIONAL PROPERTIES
// Java version (8, 9, 11, ...) used for the generated code compatibility // Example: set compatibility with Java 8 javaVersion = 8 // (default: Java 11)
// Platform configuration including custom toolchain path // Example: a custom path to the Android toolchain platforms = listOf( TargetPlatform.Android( // List of build architectures archs = listOf("<armeabi-v7a | arm64-v8a | x86 | x86_64>"), // Path to a custom toolchain location toolchain = file("<PATH TO THE TOOLCHAIN LOCATION>")) )
// Configuration for the Scade Build Tool (scd)
// Custom binary location scd = file("<SCD BINARY LOCATION>") // Auto-update for the scd build tool scdAutoUpdate = true // List of custom options passed to the scd build tool scdOptions = listOf("<OPTIONS>")}| Entry | Mandatory | Description | Default |
|---|---|---|---|
| path | Yes | Full path to your Swift Project source code | |
| product | Yes | Name of the Swift product | |
| javaVersion | No | Set Java Compatibiity Level | 11 |
| scd | No | Custom Location of the scd build tool | |
| scdAutoUpdate | No | Triggers an autoupdate of the scd build tool | true |
| scdOptions | No | Custom options to be forwarded to the scd build tool |
Note: plugin supports only dynamic library products
Real Life Example
Section titled “Real Life Example”Development
Section titled “Development”Local Installation
Section titled “Local Installation”Install the local Maven repository by executing
./gradlew publishAllToMavenLocalIn order to use locally installed plugins in your applications,
add the local Maven repository to the plugin management section in the Gradle settings file settings.gradle.kts:
pluginManagement { repositories { mavenLocal() gradlePluginPortal() }}