The Swift Android Gradle Plugin simplifies the integration of Swift libraries into Android projects. Building Swift code for Android requires a lot of boilerplate configuration and scripting. This plugin encapsulates all that complexity, providing a simple, opinionated way to build and integrate Swift libraries into your Android app. See a sample app.
Swift SDK for Android is still in alpha: checkout the setup section below on the required toolchain.
// build.gradle.kts
plugins {
// android app/lib plugin must be applied first
id("com.charlesmuchene.swift-android-gradle-plugin") version "0.1.0-alpha"
}
// settings.gradle.kts
pluginManagement {
repositories {
// ...
}
// NOTE: Plugin is not yet published to any repository
// Clone and add plugin as an included build
includeBuild("../swift-android-gradle-plugin")
}After applying the plugin, the swift config block is available to configure your build. For example, we can set the apiLevel and the abis when building a debuggable project.
swift {
apiLevel = 35
debugAbiFilters = setOf("arm64-v8a", "x86_64")
}See SAGPConfig file for all available configuration options.
The plugin supports building for 3 architectures:
- arm64-v8a
- armeabi-v7a
- x86_64
To add support for additional architectures, clone plugin and add these to Arch. The plugin can be update to receive a new supported architecture as a configuration.
The Swift Android Gradle Plugin registers and configures several tasks in the swift task group to aid in building the Swift code for your project. These tasks are invoked implicitly when you assemble/clean the library or application.
To use the plugin for your project, we need to install the required tools to cross-compile Swift for Android:
NOTE: Cross-compilation requires that the host toolchain version exactly matches the Swift SDK version.
To manage swift versions, we'll use Swiftly - a Swift toolchain installer. You can install it using homebrew or from swift.org.
To match the Swift SDK Version, we'll use dev snapshots. The current plugin version is tested against version main-snapshot-2025-10-17.
a. Download the host toolchain swiftly install main-snapshot-2025-10-17
b. Set it for use: swiftly use main-snapshot-2025-10-17
Verify the desired version is installed by running:
➜ swiftly run swift --version
Apple Swift version 6.3-dev (LLVM d8e7cc748ee6e7f, Swift a07ea37d0054945)
Target: arm64-apple-macosx15.0
Build config: +assertionsInstall the Swift SDK for Android using the official instructions at Swift SDK Bundles. The site provides a handy functionality to copy the install command.
Verify the sdk is install by running:
➜ swift sdk list
swift-DEVELOPMENT-SNAPSHOT-2025-10-17-a-android-0.1Use the Android SDK manager to install the Native Development Kit. The manager installs the NDK in a subdirectory of your main Android SDK location: ANDROID_SDK_HOME/ndk/ndk-version. If you use the default location, ANDROID_SDK_HOME should point to ~/Library/Android/sdk. If not, check the location in Android Studio via Tools > SDK Manager.
Here's a screenshot showing sdk manager tool window with (one of the) installed NDK version highlighted.
With the NDK installed:
-
Set the environment variable
ANDROID_NDK_HOMEto the location of the desired NDK version. I have NDK version:29.0.14206865therefore I have set environment variable as:export ANDROID_NDK_HOME=ANDROID_SDK_HOME/ndk/29.0.14206865. -
Link the NDK to the Swift SDK for Android by running the
setup-android-sdk.shutility script included with the Swift SDK bundle. Run the following command:~/Library/org.swift.swiftpm/swift-sdks/swift-DEVELOPMENT-SNAPSHOT-2025-10-17-a-android-0.1.artifactbundle/swift-android/scripts/setup-android-sdk.sh
For a comprehensive walkthrough on setting up Swift SDK for Android, checkout this getting started article.
😮💨 And that's it. You can now use the Swift Android Gradle Plugin and write your native libs in Swift!
For questions or support, reach out via GitHub Issues.
Contributions and suggestions are welcome! 🎉


