Getting Started with the Swift SDK for Android

Learn how to set up the Swift SDK for Android and integrate Swift code into an Android app. This tutorial covers installation, creating a Swift library, and running Swift code on Android devices. By Darryl Bayliss.

Leave a rating/review
Save for later
Share

In June 2014 Apple announced a new programming language available for use to develop for its platforms called Swift. Swift was intended to be a modern replacement to Objective-C, which has been in use by developers since the 1980’s.

Whilst Swift was initially a language owned by Apple, on December 3 2015 Apple made Swift an open source project. It also made Swift available for use on Linux operating systems, committing it self to developing Swift in the open.

Since then through open source efforts of Apple and the community Swift has found its way onto other platforms, including Windows and cloud services like AWS. Jump to October 24th 2025 and thanks to a dedicated working group, Swift has found its way onto Android.

In this tutorial you’ll understand how Swift works on Android, and go through the steps to get Swift working in a basic Android project.

What is the Swift SDK for Android?

The Swift SDK for Android provides 3 main components required to run Swift on Android. They are:

– The Host Toolchain (The compiler and tools required to build and run Swift code)
– The Swift SDK for Android (Libraries, headers and resources needed to build and run Swift code for Android)
– The Android NDK (The Native Development Kit for Android, which allow code to be run on the Android platforms in other languages)

These components work together to create machine code, which can run natively on Android devices whilst also providing the performance and safety of Swift.

Since most Android APIs are only available via Kotlin or Java, the Swift Android workgroup also provided a tool called swift-java. This generates bindings to enable swift to call through to Java code and vice versa using the Java Native Interface (JNI).

Having executable Swift code callable via the JNI means you can create reusable Swift Libraries across platforms, and call through to them via an Android app built normally. How exciting!

In the next section you’ll use the Swift SDK for Android to create a small library running in an Android app. Let’s get to it!

Setting up the Swift SDK for Android

To show the Swift SDK for Android in action, you’ll use an example project provided by the Android working group to see how Swift code is called by the Android. You’ll then improve it by writing another function in Swift that can be called by the App.

First, install Android Studio if you don’t have it, then follow the instructions here on how to run an app on a device or an emulator.

Next, clone the swift-android-examples repository to your computer. Then, open the README.md at the top of the project.

The README explains what dependencies are needed to build the app. It’s quite involved so give it a few reads before proceeding so you begin.

When you’re ready you can begin to proceed installing the dependencies. The first dependencies needed are the Swift SDK for Android and Swiftly, a toolchain manager for Swift.

Follow the instructions available here to install Swiftly. Once Swiftly is installed, install a snapshot of the Swift SDK by continuing to use the terminal:

swiftly install main-snapshot-2025-12-17

Once the snapshot is installed, tell swiftly to begin using it.

swiftly use main-snapshot-2025-12-17

Finally, test the snapshot is active by asking swift to run swift and tell you what version it is.

swiftly run swift --version

It should respond with Apple Swift version 6.3-dev (LLVM 2bc32d2793f525d, Swift f1a704763ffd2c8) Target: arm64-apple-macosx15.0 Build config: +assertions.

Once the snapshot is running correctly, you can install the Swift SDK for Android. Using the terminal enter the following command.

swift sdk install https://download.swift.org/development/android-sdk/swift-DEVELOPMENT-SNAPSHOT-2025-12-17-a/swift-DEVELOPMENT-SNAPSHOT-2025-12-17-a_android.artifactbundle.tar.gz --checksum 5b5cd4da30ececb28c678c3a17a922f3c5fdb82f0ff6dc777bd44275fcc222e0

Once the Swift SDK for Android installed, you can check it available in swiftly using the sdk list command.

swiftly run swift sdk list

The terminal should output swift-DEVELOPMENT-SNAPSHOT-2025-12-17-a_android.

With the Swift SDK for Android installed. You can now install the Native Development Kit for Android, you’ll do that in the next section.

Setting up the Native Development Kit

To download the NDK and set it up for usage, enter the following commands into the terminal.

mkdir ~/android-ndk
cd ~/android-ndk
curl -fSLO https://dl.google.com/android/repository/android-ndk-r27d-$(uname -s).zip
unzip -q android-ndk-r27d-*.zip
export ANDROID_NDK_HOME=$PWD/android-ndk-r27d

Feel free to change the location of the `android-ndk` directory if needed.

The commands create a new directory to store the NDK, then navigates into the directory. It then downloads the NDK and unzips it into the directory. Finally it adds the NDK into your terminal path for easy reference.

Once the NDK is installed and unzipped you can then link it to the Swift SDK by running a utility script provided. Enter the following command into the terminal to do that.

cd ~/Library/org.swift.swiftpm || cd ~/.swiftpm
./swift-sdks/swift-DEVELOPMENT-SNAPSHOT-2025-12-17-a_android.artifactbundle/swift-android/scripts/setup-android-sdk.sh

With that, you have setup the Swift SDK for Android successfully using NDK. The next step to run the project is to build the Java packages needed for the project using swift-java. Let’s do that next.

Building Java Packages using swift-java

To use swift-java you need to make sure the Java Development Kit (JDK) is installed on your machine. You need JDK 25 because some parts of swift-java are built using it.

The recommended way to install JDKs is to use a tool called sdkman, a package manager for software development kits.

First, install sdkman onto your machine using the terminal.

curl -s "https://get.sdkman.io" | bash

Restart the terminal so sdkman can be added to your path. Then install and set JDK 25 as your active JDK.

sdk install java 25.0.1-amzn --use # only in order to publish swift-java artifacts locally
export JAVA_HOME="${HOME}/.sdkman/candidates/java/current"

With the JDK setup, you can now begin to generate the swift-java libraries needed for the project. Navigate to the swift-android-examples project in the terminal and go into the `hashing-lib` directory.

cd hashing-lib

Run the resolve packages command from Swift to generate the packages.

swift package resolve

Finally, publish the packages to your machines local maven repo. This is a place where artifacts and binaries can be used by other projects on your machine, similar to maven central you may have used to retrieve dependencies remotely.

./.build/checkouts/swift-java/gradlew --project-dir .build/checkouts/swift-java :SwiftKitCore:publishToMavenLocal

Once the terminals report back the build was successful you can now run the app in Android Studio.