Skip to content

Add Android (aarch64) cross-compile support to SwiftTimecodeCore#86

Merged
orchetect merged 4 commits into
orchetect:mainfrom
mansbernhardt:android-support
May 16, 2026
Merged

Add Android (aarch64) cross-compile support to SwiftTimecodeCore#86
orchetect merged 4 commits into
orchetect:mainfrom
mansbernhardt:android-support

Conversation

@mansbernhardt
Copy link
Copy Markdown
Contributor

The existing Linux/Glibc/Musl arms in the libc imports cover Linux but not Android, whose Swift SDK exposes its libc as the Android module (Bionic). Without an #elseif canImport(Android) arm, the imports fall through to no-import on Android and the unqualified pow/powf/trunc calls + the ceiling / floor qualified calls fail to resolve.

Verified against the Swift 6.3 open-source toolchain (org.swift.630202603201a) with the Android Swift SDK artifact bundle (android28+) — swift build --target SwiftTimecodeCore --swift-sdk aarch64-unknown-linux-android28 produces an ELF aarch64 .o.

Also adds a GitHub Actions job that runs the same cross-compile in CI so future regressions surface immediately.

Files changed:

  • Sources/SwiftTimecodeCore/Utilities/Outsourced/FloatingPoint and Darwin.swift: add canImport(Android) → import Android in 3 places (top imports, ceiling, floor).
  • Sources/SwiftTimecodeCore/Timecode/Protocol Adoptions/Strideable.swift: add canImport(Android) → import Android in the imports block.
  • .github/workflows/build.yml: new android job builds SwiftTimecodeCore for aarch64-android28 using vapor/swiftly-action to install Swift 6.3 + the Android SDK artifact bundle.

mansbernhardt and others added 3 commits May 9, 2026 18:33
The existing Linux/Glibc/Musl arms in the libc imports cover Linux but
not Android, whose Swift SDK exposes its libc as the `Android` module
(Bionic). Without an `#elseif canImport(Android)` arm, the imports fall
through to no-import on Android and the unqualified `pow`/`powf`/`trunc`
calls + the `ceiling` / `floor` qualified calls fail to resolve.

Verified against the Swift 6.3 open-source toolchain
(org.swift.630202603201a) with the Android Swift SDK artifact bundle
(android28+) — `swift build --target SwiftTimecodeCore --swift-sdk
aarch64-unknown-linux-android28` produces an ELF aarch64 .o.

Also adds a GitHub Actions job that runs the same cross-compile in CI
so future regressions surface immediately.

Files changed:
- Sources/SwiftTimecodeCore/Utilities/Outsourced/FloatingPoint and Darwin.swift:
    add canImport(Android) → import Android in 3 places (top imports,
    `ceiling`, `floor`).
- Sources/SwiftTimecodeCore/Timecode/Protocol Adoptions/Strideable.swift:
    add canImport(Android) → import Android in the imports block.
- .github/workflows/build.yml:
    new `android` job builds SwiftTimecodeCore for aarch64-android28
    using vapor/swiftly-action to install Swift 6.3 + the Android SDK
    artifact bundle.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`vapor/swiftly-action@v0.2 toolchain: "6.3"` is a floating selector — when
Swift 6.3.1 shipped, CI started picking that up and failing to load the
Android SDK's pre-built `.swiftmodule` files (which were compiled by 6.3.0).
Swift's stable ABI covers the runtime, not the swiftmodule binary format —
that requires an exact-version compiler match.
Pin to "6.3.0" to track the Android SDK artifactbundle (also pinned to
6.3-RELEASE). Bump both in lockstep when swift.org publishes a 6.3.1 or
6.4 Android SDK bundle (currently 404).
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.
@orchetect
Copy link
Copy Markdown
Owner

Thanks very much for the submission - I will have a look at this soon.

@orchetect
Copy link
Copy Markdown
Owner

orchetect commented May 15, 2026

I'm just going to update the CI workflow, as I've recently built a custom Swift Android SDK setup action that I use for all of my Swift repos.

It performs all the boilerplate necessary to download and setup the SDK. It supports all versions of the SDK available, so whatever Swift toolchain the runner has can be used which means pinning versions is not necessary and makes it more maintainable as new Swift toolchains and Android SDKs are released.

@orchetect orchetect self-assigned this May 15, 2026
@orchetect orchetect merged commit 88591f7 into orchetect:main May 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants