Skip to content

Commit 00e2fe7

Browse files
committed
Update instructions for Swift 6.2 SDK, ndk 27d, and add some wording tweaks
1 parent 7a81b4d commit 00e2fe7

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

documentation/articles/swift-android-getting-started.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
22
layout: page
33
date: 2025-06-01 12:00:00
4-
title: Getting Started with the Swift Android SDK
4+
title: Getting Started with the Swift SDK for Android
55
author: [marcprux]
66
---
77

8-
Since it was first open-sourced in 2015, Swift has grown from a language focused on creating apps for Darwin based systems (iOS, macOS, etc.) into a cross-platform development language supporting Linux, Windows, and various embedded systems. With the release of the Swift Android SDK, it is now possible to use Swift for Android application development as well.
8+
Since it was first open-sourced in 2015, Swift has grown from a language focused on creating apps for Darwin-based systems (iOS, macOS, etc.) into a cross-platform development language supporting Linux, Windows, and various embedded systems. With the release of the Swift SDK for Android, it is now possible to use Swift for Android application development as well.
99

1010
### Getting Started
1111

12-
Building a Swift package for Android involves installing and configuring a cross-compilation SDK. Cross-compilation is the process of building code on one platform (the host) to run on a different platform (the target). In the context of Swift for Android, this typically involves compiling Swift code on a macOS or Linux machine (the host) to produce executables or libraries for Android devices (the target). This differs from compiling Swift for the host platform, where the host and target are the same (e.g., compiling and running Swift code on macOS for macOS).
12+
Building a Swift package for Android involves installing and configuring a cross-compilation SDK. Cross-compilation is the process of building code on one platform, the host, to run on a different platform, the target. In the context of Swift for Android, this typically involves compiling Swift code on a host macOS or Linux machine to produce executables or libraries for the target Android OS. This differs from compiling Swift for the host platform, where the host and target are the same (e.g., compiling and running Swift code on macOS for macOS).
1313

1414
To cross-compile Swift code for Android, you need three separate components:
1515

1616
1. **The Host Toolchain**: this is the `swift` command and related tools that you will use to build and run your Swift code.
17-
2. **The Swift Android SDK**: the set of libraries, headers, and other resources needed to generate and run Swift code for the Android target.
18-
3. **The Android NDK**: the "native development kit" for Android includes the cross-compilation tools like `clang` that are used by the host toolchain to perform compilation and linking.
17+
2. **The Swift SDK for Android**: the set of libraries, headers, and other resources needed to generate and run Swift code for the Android target.
18+
3. **The Android NDK**: the "Native Development Kit" for Android includes the cross-compilation tools like `clang` and `ld` that are used by the host toolchain to cross-compile and perform linking.
1919

2020

2121
#### 1. Install the Host Toolchain
@@ -25,56 +25,56 @@ The first thing to note is that while `swift` may already be installed on your s
2525
The easiest and recommended way to manage host toolchains on macOS and Linux is to use the [swiftly](https://www.swift.org/swiftly/documentation/swiftly/getting-started) command. Once that has been setup, you can install the host toolchain with:
2626

2727
```console
28-
$ swiftly install 6.1.1
29-
Installing Swift 6.1.1
28+
$ swiftly install 6.2
29+
Installing Swift 6.2
3030
Installing package in user home directory...
31-
Swift 6.1.1 installed successfully!
31+
Swift 6.2 installed successfully!
3232

33-
$ swiftly use 6.1.1
34-
The global default toolchain has been set to `Swift 6.1.1` (was 6.1.0)
33+
$ swiftly use 6.2
34+
The global default toolchain has been set to `Swift 6.2` (was 6.1.0)
3535

3636
$ swiftly run swift --version
37-
Apple Swift version 6.1.1 (swift-6.1.1-RELEASE)
37+
Apple Swift version 6.2 (swift-6.2-RELEASE)
3838
Target: arm64-apple-macosx15.0
3939
```
4040

41-
#### 2. Install the Swift Android SDK
41+
#### 2. Install the Swift SDK for Android
4242

43-
Next, you can download and install the SDK bundle using the built-in `swift sdk` command:
43+
Next, download and install the SDK bundle using the built-in `swift sdk` command:
4444

4545
```console
46-
$ curl -fSLO https://github.com/skiptools/swift-android-toolchain/releases/download/6.1.1/swift-6.1.1-RELEASE-android-0.1.artifactbundle.tar.gz
47-
$ swiftly run swift sdk install swift-6.1.1-RELEASE-android-0.1.artifactbundle.tar.gz
48-
Swift SDK bundle at `swift-6.1.1-RELEASE-android-0.1.artifactbundle.tar.gz` successfully installed as swift-6.1.1-RELEASE-android-0.1.artifactbundle.
46+
$ swift sdk install https://github.com/swift-android-sdk/swift-android-sdk/releases/download/6.2/swift-6.2-RELEASE-android-0.1.artifactbundle.tar.gz --checksum ca7e09f09a591b6a661a39134aaf53b1b59d5e3a193b271ab1f20effdfc6e88e
47+
48+
Swift SDK bundle at `swift-6.2-RELEASE-android-0.1.artifactbundle.tar.gz` successfully installed as swift-6.2-RELEASE-android-0.1.artifactbundle.
4949
```
5050

5151
You should now see the Android SDK included in the `swift sdk list` command:
5252

5353
```console
5454
$ swiftly run swift sdk list
55-
swift-6.1.1-RELEASE-android-0.1
55+
swift-6.2-RELEASE-android-0.1
5656
```
5757

5858
#### 3. Install and configure the Android NDK
5959

60-
The Swift Android SDK depends on the Android Native Development Toolkit (NDK) version 27c to provide the headers and tools necessary for cross-compiling to Android architectures. There are a variety of ways to [install the Android NDK](https://developer.android.com/ndk/guides), but the simplest is to just download and unzip the archive from the [NDK Downloads page](https://developer.android.com/ndk/downloads/#lts-downloads) directly.
60+
The Swift SDK for Android depends on the Android Native Development Toolkit (NDK) version 27d to provide the headers and tools necessary for cross-compiling to Android architectures. There are a variety of ways to [install the Android NDK](https://developer.android.com/ndk/guides), but the simplest is to just download and unzip the archive from the [NDK Downloads page](https://developer.android.com/ndk/downloads/#lts-downloads) directly.
6161

6262
You can automate this with the following commands in a directory of your choosing:
6363

6464
```console
6565
$ mkdir ~/android-ndk
6666
$ cd ~/android-ndk
67-
$ curl -fSLO https://dl.google.com/android/repository/android-ndk-r27c-$(uname -s).zip
68-
$ unzip -q android-ndk-r27c-*.zip
69-
$ export ANDROID_NDK_HOME=$PWD/android-ndk-r27c
67+
$ curl -fSLO https://dl.google.com/android/repository/android-ndk-r27d-$(uname -s).zip
68+
$ unzip -q android-ndk-r27d-*.zip
69+
$ export ANDROID_NDK_HOME=$PWD/android-ndk-r27d
7070
```
7171

72-
Once you have downloaded and unpacked the NDK, you can link it up to the Swift Android SDK by running the `setup-android-sdk.sh` utility script included with the SDK bundle:
72+
Once you have downloaded and unpacked the NDK, you can link it up to the Swift SDK for Android by running the `setup-android-sdk.sh` utility script included with the SDK bundle:
7373

7474
```console
7575
$ cd ~/Library/org.swift.swiftpm || cd ~/.swiftpm
76-
$ ./swift-sdks/swift-6.1.1-RELEASE-android-0.1.artifactbundle/swift-android/scripts/setup-android-sdk.sh
77-
setup-android-sdk.sh: success: ndk-sysroot linked to Android NDK at android-ndk-r27c/toolchains/llvm/prebuilt
76+
$ ./swift-sdks/swift-6.2-RELEASE-android-0.1.artifactbundle/swift-android/scripts/setup-android-sdk.sh
77+
setup-android-sdk.sh: success: ndk-sysroot linked to Android NDK at android-ndk-r27d/toolchains/llvm/prebuilt
7878
```
7979

8080
*Note that if you have already installed the NDK in a different location, you can simply set the `ANDROID_NDK_HOME` environment variable to that location and run the `setup-android-sdk.sh`*
@@ -108,7 +108,7 @@ $ .build/debug/hello
108108
Hello, world!
109109
```
110110

111-
With the Swift Android SDK installed and configured, you can now cross-compile the executable for Android for the `x86_64` architecture:
111+
With the Swift SDK for Android installed and configured, you can now cross-compile the executable for Android for the `x86_64` architecture:
112112

113113
```console
114114
$ swiftly run swift build --swift-sdk x86_64-unknown-linux-android28 --static-swift-stdlib
@@ -151,6 +151,6 @@ Congratulations, you have built and run your first Swift program on Android!
151151

152152
Note that Android applications are typically not deployed as command-line executable tools. Rather, they are assembled into an `.apk` archive and launched as an app from the home screen. To support this, Swift modules can be built as shared object libraries for each supported architecture and included in the app archive. The Swift code can then be accessed from the Android app — which is typically written in Java or Kotlin — through the Java Native Interface ([JNI](https://developer.android.com/training/articles/perf-jni)).
153153

154-
This is a larger development topic that will be expanded on in future articles and documentation. In the meantime, please visit the [Swift Android forums](https://forums.swift.org/c/development/android/) to discuss and seek help with the Swift Android SDK.
154+
This is a larger development topic that will be expanded on in future articles and documentation. In the meantime, please visit the [Swift Android forums](https://forums.swift.org/c/platform/android/115) to discuss and seek help with the Swift SDK for Android.
155155

156156

0 commit comments

Comments
 (0)