Skip to content

Commit ce78c6c

Browse files
committed
CI: install Android NDK r27d and run SDK setup script
The previous swift sdk install was incomplete — it only fetches Swift-side artifacts (stdlib, Foundation .swiftmodule files). C interop in SwiftOverlayShims needs the NDK's C sysroot (semaphore.h, libc, etc.), and the SDK bundle's destination JSON needs ANDROID_NDK_HOME baked in by the setup-android-sdk.sh script that ships with it. Without these, the build errors mid-compile with: 'semaphore.h' file not found … could not build C module 'SwiftOverlayShims' NDK r27d is paired with swift-6.3-RELEASE Android SDK — bump both together when swift.org publishes a newer SDK bundle.
1 parent 3211ebd commit ce78c6c

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,33 @@ jobs:
138138
uses: vapor/swiftly-action@v0.2
139139
with:
140140
toolchain: "6.3.0"
141+
- name: Install Android NDK r27d
142+
# `swift sdk install` only fetches the Swift-side stdlib + Foundation for Android.
143+
# The NDK supplies the C sysroot (libc, libm, semaphore.h, …) that the SwiftOverlayShims
144+
# C module needs to compile. Without these the cross-compile errors with
145+
# 'semaphore.h' file not found … could not build C module 'SwiftOverlayShims'
146+
# mid-build. r27d matches the swift-6.3-RELEASE Android SDK bundle's expected NDK
147+
# version — bump in lockstep with the SDK URL above.
148+
run: |
149+
wget -q "https://dl.google.com/android/repository/android-ndk-r27d-linux.zip" -O /tmp/ndk.zip
150+
unzip -q /tmp/ndk.zip -d /opt
151+
echo "ANDROID_NDK_HOME=/opt/android-ndk-r27d" >> "$GITHUB_ENV"
141152
- name: Install Android Swift SDK
142153
run: |
143154
swift sdk install \
144155
https://download.swift.org/swift-6.3-release/android-sdk/swift-6.3-RELEASE/swift-6.3-RELEASE_android.artifactbundle.tar.gz \
145156
--checksum 2f2942c4bcea7965a08665206212c66991dabe23725aeec7c4365fc91acad088
157+
# The bundle ships a setup script that wires NDK_HOME paths into the SDK's
158+
# destination JSON. Without running it, the compiler can find the Swift
159+
# stdlib but not the NDK's C headers — yielding the SwiftOverlayShims error.
160+
# On ubuntu-latest runners the bundle lands under ~/.config/swiftpm/swift-sdks/
161+
# (vs. ~/.swiftpm/swift-sdks/ in containerised runs).
162+
SETUP_SCRIPT=$(find "$HOME/.config/swiftpm/swift-sdks" "$HOME/.swiftpm/swift-sdks" -name "setup-android-sdk.sh" 2>/dev/null | head -1)
163+
if [ -z "$SETUP_SCRIPT" ]; then
164+
echo "setup-android-sdk.sh not found. Searched paths:"
165+
find "$HOME/.config/swiftpm" "$HOME/.swiftpm" 2>/dev/null | head -20
166+
exit 1
167+
fi
168+
bash "$SETUP_SCRIPT"
146169
- name: Build for Android (aarch64)
147170
run: swift build --target SwiftTimecodeCore --swift-sdk aarch64-unknown-linux-android28

0 commit comments

Comments
 (0)