# Getting Started with Swift on Android

**URL:** <https://forums.swift.org/t/getting-started-with-swift-on-android/90647>\
**Category:** Android\
**Tags:** android, cross-compilation, tutorial\
**Created:** [November 11, 2026, 7:04am UTC](https://forums.swift.org/t/getting-started-with-swift-on-android/90647 "2026-11-11T07:04:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dheerendra](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dheerendra/32/47241_2.png) [@dheerendra](https://forums.swift.org/u/dheerendra)\
**Post date:** [November 11, 2026, 7:04am UTC](https://forums.swift.org/t/getting-started-with-swift-on-android/90647/1 "2026-11-11T07:04:03Z")

</div>

_A beginner-friendly introduction to the official Swift SDK for Android_

## 1. Introduction

For most of its life, Swift was known as the language for iPhone, iPad and Mac apps. That changed with Swift 6.3, which shipped the first official Swift SDK for Android. You can now compile Swift code for Android devices using official tools published on [swift.org](http://swift.org), instead of relying on unofficial community toolchains.

This tutorial walks you through the whole path from zero: what the pieces are, how to install them, how to build your first Swift program for Android, and how Swift fits into a real Android app. No previous Android experience is needed, but basic familiarity with Swift and the terminal will help.

**What you will learn**

- What the Swift SDK for Android is, and what it is not
- How to install the toolchain, the SDK and the Android NDK
- How to cross-compile and run a "Hello, world" program on an emulator or device
- How to share Swift code between an iOS app and an Android app

## 2. How it works: the three pieces

Building Swift for Android needs three components that work together:

| Component | What it does |
| --- | --- |
| **Host toolchain** | The Swift compiler and tools running on your Mac or Linux machine. |
| **Swift SDK for Android** | Libraries, headers and resources that let the compiler target Android (a cross-compilation SDK). |
| **Android NDK** | Google's Native Development Kit, which provides the Android system libraries your Swift code links against. |

> **Important:** Xcode cannot build Android apps by itself. The Swift SDK for Android is used from the command line (Swift Package Manager) or from Android Studio via Gradle. SwiftUI and UIKit do not run on Android; for the user interface you typically use Kotlin with Jetpack Compose, or a third-party tool such as Skip.

## 3. Prerequisites

- A Mac (macOS) or a Linux machine
- Android Studio, with an emulator set up or a physical Android device with USB debugging enabled
- Around 5 GB of free disk space for the toolchain, SDK and NDK
- A terminal you are comfortable using

## 4. Step-by-step setup

### Step 1: Install swiftly

swiftly is the official Swift toolchain manager. It lets you install and switch between Swift versions. On macOS:

```bash
curl -O https://download.swift.org/swiftly/darwin/swiftly.pkg && \
installer -pkg swiftly.pkg -target CurrentUserHomeDirectory && \
~/.swiftly/bin/swiftly init --quiet-shell-followup && \
. "${SWIFTLY_HOME_DIR:-$HOME/.swiftly}/env.sh" && \
hash -r

```

On Linux, follow the swiftly instructions at [swift.org/install](https://www.swift.org/install/).

### Step 2: Install a matching Swift toolchain

The host toolchain must be the same version as the Android SDK you install next. For example, for the latest release:

```bash
swiftly install latest
swiftly use latest
swift --version

```

### Step 3: Install the Swift SDK for Android

Go to [swift.org/install](https://www.swift.org/install/), open the Android section, and copy the install command for the SDK that matches your toolchain version. It looks like this:

```bash
swift sdk install <SDK-URL-FROM-SWIFT.ORG>.artifactbundle.tar.gz \
  --checksum <CHECKSUM-FROM-SWIFT.ORG>

```

> **Tip:** Always copy the URL and checksum from [swift.org](http://swift.org) rather than from a blog post. The checksum protects you from a corrupted or tampered download, and it changes with every release.

Check that it installed correctly:

```bash
swift sdk list
# Example output:
# swift-6.x-RELEASE_android

```

### Step 4: Install the Android NDK and link it

In Android Studio, open **Settings \> Languages & Frameworks \> Android SDK \> SDK Tools** , tick **NDK (Side by side)** and install the version recommended in the [swift.org](http://swift.org) Android guide. Then point your shell at it:

```bash
export ANDROID_HOME=$HOME/Library/Android/sdk # on Linux, usually $HOME/Android/Sdk
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/<your-ndk-version>
export PATH=$PATH:$ANDROID_HOME/platform-tools

```

Finally, run the setup script that ships inside the SDK bundle. It links the NDK to the Swift SDK:

```bash
cd ~/Library/org.swift.swiftpm || cd ~/.swiftpm
./swift-sdks/<your-sdk-name>.artifactbundle/swift-android/scripts/setup-android-sdk.sh

```

You should see a success message saying the NDK sysroot was linked.

## 5. Your first Swift program on Android

### Step 5: Create a package

```bash
mkdir hello && cd hello
swift package init --type executable
swift build
.build/debug/hello # prints: Hello, world!

```

This first build runs on your own machine. Now cross-compile the same code for Android.

### Step 6: Cross-compile for Android

```bash
# For the emulator (x86_64):
swift build --swift-sdk x86_64-unknown-linux-android28 --static-swift-stdlib

# For a real phone (arm64):
swift build --swift-sdk aarch64-unknown-linux-android28 --static-swift-stdlib

```

The number `28` is the minimum Android API level (Android 9). `--static-swift-stdlib` bundles the Swift standard library into the binary so you don't have to copy it separately.

### Step 7: Run it on the emulator or device

Start your emulator (or connect your phone), then push the binary plus the C++ runtime from the NDK and run it:

```bash
adb push .build/x86_64-unknown-linux-android28/debug/hello /data/local/tmp/
adb push $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/*/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so /data/local/tmp/
adb shell "cd /data/local/tmp && LD_LIBRARY_PATH=. ./hello"
# Hello, world!

```

> **Congratulations!** You just ran Swift code on Android. For a real phone, swap `x86_64` for `aarch64` in both `adb push` paths.

## 6. Writing code that works on both platforms

The most practical use of Swift on Android today is sharing your app's core logic: models, validation, networking and business rules. You write it once in a Swift package and use it in both apps. When something needs to differ, use a compile-time platform check:

```swift
public struct Greeter {
    public init() {}

    public func greeting(for name: String) -> String {
        #if os(Android)
        let platform = "Android"
        #elseif os(iOS)
        let platform = "iOS"
        #else
        let platform = "another platform"
        #endif
        return "Hello, \(name)! Running Swift on \(platform)."
    }
}

```

Many existing packages already work: more than a quarter of the libraries on the Swift Package Index were marked as Android-compatible when the SDK launched. Check a package's page on [swiftpackageindex.com](https://swiftpackageindex.com) before you depend on it.

## 7. From a program to a real Android app

Running a terminal program is the first milestone. To build an actual app with screens, you have two main options:

**Option A: Kotlin UI + shared Swift logic**  
Build the user interface in Android Studio with Kotlin and Jetpack Compose, and call your Swift package from Kotlin using [swift-java](https://github.com/swiftlang/swift-java), the official Java/Kotlin interoperability project. The official [swift-android-examples](https://github.com/swiftlang/swift-android-examples) repository shows complete working setups. This is the best fit for teams that already have an Android app.

**Option B: SwiftUI everywhere with Skip**  
[Skip](https://skip.dev) is a third-party tool that works inside Xcode. You write a SwiftUI app and Skip produces a native Android version, running on the iOS simulator and an Android emulator side by side. It is the closest thing to "Xcode for Android". Check its website for current features and pricing.

## 8. Common problems and fixes

| Problem | Fix |
| --- | --- |
| `swift sdk list` shows nothing | The SDK install failed or ran with a different toolchain. Re-run the install command with the toolchain active. |
| Build errors about missing headers or sysroot | The NDK isn't linked. Re-run `setup-android-sdk.sh` after setting `ANDROID_NDK_HOME`. |
| Version mismatch error | Toolchain and SDK versions must match exactly. Check with `swift --version`. |
| `libc++_shared.so` not found on device | Push it from the NDK sysroot (Step 7) and set `LD_LIBRARY_PATH`. |
| "Exec format error" on device | Wrong architecture. Use `x86_64` for most emulators and `aarch64` for phones. |

## 9. Resources

- Official getting-started guide: [swift.org/documentation/articles/swift-sdk-for-android-getting-started.html](https://www.swift.org/documentation/articles/swift-sdk-for-android-getting-started.html)
- Downloads and install commands: [swift.org/install](https://www.swift.org/install/)
- Java/Kotlin interop: [github.com/swiftlang/swift-java](https://github.com/swiftlang/swift-java)
- Example apps: [github.com/swiftlang/swift-android-examples](https://github.com/swiftlang/swift-android-examples)
- Skip: [skip.dev](https://skip.dev)

## 10. Wrapping up

Swift on Android is young but official, and it is improving with every release. Start small: get "Hello, world" running, then move one piece of shared logic, such as a model or a validation rule, into a Swift package that both your iOS and Android apps use. Feedback and questions are welcome in the replies below!
