This repository contains convenience scripts for building the upstream Swift SDK generator and then producing Swift SDK bundles for Linux distributions used by Swift Embedded Linux projects.
Important:
- These scripts require Swift 6.0 or later.
- They currently support generating and testing Swift 6.0 or later Swift SDKs only.
- These scripts only support generating Swift SDKs for Debian and Ubuntu distributions since armv7 support is required.
- Docker is not required for generating these Swift SDKs as only the package-based builds are used with the SDK generator.
- Raspberry Pi OS is not supported since the SDK generator does not support it (yet).
Follow these steps in order.
-
Install Swift 6.0 or later
Make sure your local toolchain is Swift 6.0+ before running any of the scripts.
swift --version
You should see a Swift 6.0+ release, such as 6.0, 6.1, 6.3, or 6.4.
NOTE: This is best used with swiftly, which can be installed from Swift.org. With swiftly it is then easy to switch Swift versions before generating and testing Swift SDKs that require those versions of Swift.
-
Ensure that needed dependencies are installed
These are required for building and running the SDK generator.
Debian/Ubuntu:
sudo apt install libsqlite3-dev zstd xz-utils
RHEL/Fedora:
sudo dnf install zstd xz
macOS:
brew install xz zstd
-
Clone this repository and enter it
git clone https://github.com/swift-embedded-linux/generate-linux-sdks.git cd generate-linux-sdks -
Build the SDK generator
This script checks out or updates the upstream generator project, then builds it in release mode with a static Swift standard library.
./build-sdk-generator.swift
This prepares the generator at:
swift-sdk-generator/.build/release/swift-sdk-generator
-
Generate Swift SDK bundles
The main script generates Linux Swift SDK bundles for multiple target architectures.
./generate-linux-sdks.swift 6.4.0 ubuntu noble --test
This example does two things:
- generates bundles for
x86_64,aarch64, andarmv7 - runs the test project against the generated SDKs for the requested Swift version
The arguments are:
6.4.0= Swift version to targetubuntu= Linux distribution namenoble= distribution version--test= optional; validates the result using the local test project
If you only want to generate the bundles without testing, omit the final option:
./generate-linux-sdks.swift 6.4.0 ubuntu noble
- generates bundles for
-
Check the generated bundles
Generated artifact bundles appear under the generator’s
Bundlesdirectory:ls -1 swift-sdk-generator/Bundles
Typical output looks like this:
6.4.0-RELEASE_ubuntu_noble_aarch64.artifactbundle 6.4.0-RELEASE_ubuntu_noble_armv7.artifactbundle 6.4.0-RELEASE_ubuntu_noble_x86_64.artifactbundle -
(Optional): Clean up generated bundles when needed
./clean-linux-sdks.swift
This prompts for confirmation before deleting all generated SDK bundle directories in
swift-sdk-generator/Bundles.Or, just delete the entire
swift-sdk-generatordirectory if you want to completely cleanup.
This script keeps the underlying swift-sdk-generator project up to date and rebuilds it locally.
-
clones the generator repo if it is missing
-
runs
git pull origininswift-sdk-generator -
builds the generator in release mode with:
swift build -c release --static-swift-stdlib
./build-sdk-generator.swift <branch>branch: optional branch name to checkout, pull, and build.- If not specified, the default branch from the repo will be used.
- If a branch was previously checked out, excluding this parameter will then continue using that branch.
- This is the first step in the workflow.
- The script is intentionally designed to make it easy to switch host Swift versions without rebuilding the generator repeatedly- it only needs to be built once before using it against different Swift versions and target distributions.
- It is meant to work with the upstream Swift SDK generator project in the sibling
swift-sdk-generatordirectory.
This is the main orchestration script for generating Linux Swift SDK bundles.
./generate-linux-sdks.swift <swift-version> <distribution-name> <distribution-version> [--test|--install]swift-version: target Swift version, for example6.0,6.3.3, or6.4.0distribution-name: Linux distribution name, such asubuntuordebiandistribution-version: distribution release, such asnoble,bookworm, orjammy--test: optional; runs the local validation project against the generated SDK bundles--install: accepted by the script but currently stubbed out; installation support is not implemented yet
Generate SDKs for Ubuntu 24.04 using Swift 6.4:
./generate-linux-sdks.swift 6.4.0 ubuntu nobleGenerate and validate SDKs for Debian 12 using Swift 6.3.3:
./generate-linux-sdks.swift 6.3.3 debian bookworm --testFor each target architecture in:
x86_64aarch64armv7
it runs the generator command and produces a bundle named like:
6.4.0-RELEASE_ubuntu_noble_x86_64.artifactbundle
For armv7, the script also downloads the matching armv7 runtime archive before invoking the generator.
When --test is supplied, the script validates that the host toolchain matches the requested Swift version before building the sample project.
It then runs:
swift build -c debug --build-tests --swift-sdks-path <bundles-dir> --swift-sdk <sdk-name>
swift build -c release --swift-sdks-path <bundles-dir> --swift-sdk <sdk-name>The test workflow uses the project in test-project and checks the generated binaries with file.
The testing path enforces a matching host Swift version and is intended for Swift 6.0+ only.
This script removes generated Swift SDK bundles from the generator’s Bundles directory.
./clean-linux-sdks.swift- checks whether
swift-sdk-generator/Bundlesexists - prints every bundle it is about to delete
- asks for confirmation
- deletes only after the user enters
y
./clean-linux-sdks.swift
The following Swift SDKs will be cleaned up:
6.4.0-RELEASE_ubuntu_noble_aarch64.artifactbundle
6.4.0-RELEASE_ubuntu_noble_armv7.artifactbundle
6.4.0-RELEASE_ubuntu_noble_x86_64.artifactbundle
Are you sure you want to delete all Swift SDKs in swift-sdk-generator/Bundles? (y/n): yThis repo is intentionally scoped to Swift 6.0 and later.
Examples of supported target versions include:
6.06.0.x6.1.x6.2.x6.3.x6.4.x
The scripts normalize 6.4 to 6.4.0 internally and expect the host swift tool to be a compatible Swift 6 toolchain when validating generated SDKs.
./build-sdk-generator.swift
./generate-linux-sdks.swift 6.4.0 ubuntu noble --test
ls -1 swift-sdk-generator/BundlesThis is the standard path for creating and validating Linux Swift SDK bundles with this repo.