Skip to content

Commit 2559564

Browse files
authored
Merge pull request #18 from PureSwift/feature/android
Add official Swift SDK cross-build for Android
2 parents 2cfe061 + 4cb3604 commit 2559564

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/swift.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,43 @@ jobs:
5555
brew install skiptools/skip/skip || (brew update && brew install skiptools/skip/skip)
5656
skip android sdk install --version ${{ matrix.swift }}
5757
ANDROID_NDK_ROOT="" skip android build --arch ${{ matrix.arch }}
58+
59+
android-sdk:
60+
name: Android (Swift SDK, ${{ matrix.triple }})
61+
runs-on: ubuntu-latest
62+
container: swift:6.3.2
63+
timeout-minutes: 30
64+
strategy:
65+
fail-fast: false
66+
matrix:
67+
triple: ["aarch64-unknown-linux-android28", "x86_64-unknown-linux-android28"]
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
- name: Swift Version
72+
run: swift --version
73+
- name: Install dependencies
74+
run: apt-get update -y && apt-get install -y curl unzip
75+
- name: Install Android Swift SDK
76+
run: |
77+
set -eux
78+
url="https://download.swift.org/swift-6.3.2-release/android-sdk/swift-6.3.2-RELEASE/swift-6.3.2-RELEASE_android.artifactbundle.tar.gz"
79+
curl -fsSL "$url" -o android.artifactbundle.tar.gz
80+
swift sdk install android.artifactbundle.tar.gz
81+
swift sdk list
82+
- name: Install and configure the Android NDK
83+
run: |
84+
set -eux
85+
unset ANDROID_NDK_ROOT
86+
sdk_dir="$(find / -maxdepth 8 -type d -path '*swift-6.3.2-RELEASE_android.artifactbundle/swift-android' 2>/dev/null | head -1)"
87+
test -n "$sdk_dir"
88+
cd "$sdk_dir"
89+
curl -fSL -o ndk.zip "https://dl.google.com/android/repository/android-ndk-r27d-Linux.zip"
90+
unzip -qo ndk.zip
91+
echo "ANDROID_NDK_HOME=$PWD/android-ndk-r27d" >> "$GITHUB_ENV"
92+
ANDROID_NDK_HOME="$PWD/android-ndk-r27d" ./scripts/setup-android-sdk.sh
93+
- name: Build
94+
run: |
95+
set -eux
96+
unset ANDROID_NDK_ROOT
97+
swift build --swift-sdk ${{ matrix.triple }} --static-swift-stdlib

0 commit comments

Comments
 (0)