Skip to content

Getting Started

Alexandr Esilevich edited this page Sep 27, 2024 · 13 revisions

Installation

The easiest way to install the Swift Toolchain for Android is by installing scd, the SCADE Build Tool, via the Homebrew package manager. The scd tool will install all the necessary components for building Swift code for Android. To install scd via Brew, run the following command:

brew install scade-platform/toolchain/scd

Creating Swift SPM project

You can create a new SPM project with the swift package command:

mkdir AndroidHelloWorld
cd AndroidHelloWorld
swift package init

Building SPM project for Android

To build newly created SPM project for Android platform, execute the scd build command:

scd build --platform android-arm64-v8a

This command will build the project for the ARM64 architecture for Android.

Archiving SPM project for multiple Android architectures

The scd build tool can build an SPM project for multiple Android architectures and archive it into a single directory suitable for embedding into Android projects. To create an archive, run the scd archive command with the set of Android platforms you want to build:

scd archive --platform android-arm64-v8a \
            --platform android-x86_64 \
            --platform android-armeabi-v7a \
            --platform android-x86

The resulting archive directory will be placed into the lib subdirectory of the current working directory. You can change the output directory using the -o argument.

Clone this wiki locally