Fork of the official Swift SDK for Android that includes Readdle's patches. This SDK can be used on any platform that supports the official Swift toolchain installed via swiftly.
Prebuilt SDKs are located on GitHub Releases.
- Install Swift toolchain 6.2.1 with swiftly
swiftly install 6.2.1
- Install Android NDK 27d
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install "ndk;27.3.13750724"
- Install Readdle Swift Android SDK
swift sdk install https://github.com/readdle/swift-android-toolchain/releases/download/6.2-r1/readdle-swift-6.2.1-RELEASE_android.artifactbundle.tar.gz --checksum 2057ecd9cf71fcd9beaded08d370f4815f867983c073f2d0010796aefdf8c2f1
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/27.3.13750724
~/Library/org.swift.swiftpm/swift-sdks/readdle-swift-6.2.1-RELEASE_android.artifactbundle/swift-android/scripts/setup-android-sdk.sh
Swift Android Build Tools provide the swift-android command that wraps Swift Package Manager for cross-compiling and testing on Android devices.
git clone https://github.com/readdle/swift-android-buildtools.git
export PATH="$PATH:/path/to/swift-android-buildtools"
swift-android build is a wrapper over swift build configured for Android. You can pass any Swift PM flags directly.
swift-android build
- Build with tests
swift-android build --build-tests
- Debug
swift-android build -Xswiftc -DDEBUG
- Release
swift-android build -c release
- Target a specific architecture
SWIFT_ANDROID_ARCH=x86_64 swift-android build
swift-android test builds, deploys, and runs XCTest suites on a connected Android device via ADB.
swift-android test
- Run a specific test case
swift-android test -Xtest MyModuleTests.SomeTestClass/testSpecificCase
- Run on exact device
swift-android test --device DEVICE_SERIAL
- Build and push without running
swift-android test --deploy
- Just re-run tests on device
swift-android test --fast
See Swift Android Build Tools documentation for the full reference.
Swift Android Gradle plugin integrates Swift builds into your Android Studio project. It uses swiftly and the Swift Android SDK under the hood.
- Add to your root
build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.readdle.android.swift:gradle:6.2'
}
}- Apply the plugin in your project
build.gradle:
apply plugin: 'com.readdle.android.swift'Place your Swift package inside app/src/main/swift and build with ./gradlew assembleDebug.
| Gradle | SwiftPM |
|---|---|
| ./gradlew swiftClean | swift package clean |
| ./gradlew swiftBuildDebug | swift build |
| ./gradlew swiftBuildRelease | swift build --configuration release |
See Swift Android Gradle plugin documentation for the full configuration reference.
The SDK can be built using Docker or locally on Ubuntu 24.04.
./build-docker tag:swift-6.2.1-RELEASE ./output-dir
./build-local tag:swift-6.2.1-RELEASE ./output-dir
Both scripts accept a Swift version specifier and a working directory for the build output.