Skip to content

Add support for Android #1366

Open

Description

@grynspan

Add support for Android:

  • Audit our platform-specific code and add branches for Android (mostly, but not entirely, the same as Linux)
  • Set up team workstations or VMs
  • Set up CI jobs

Activity

  1. added
    enhancementNew feature or request
    android🤖 Android support
    new-platform-support🌟 Boldly go where no `#expect` macro has gone before (to a new platform)
    on Oct 15, 2025
  2. added theissue type on Oct 15, 2025
  3. moved this to In Progress in Swift on Androidon Oct 16, 2025
  4. finagolfin commented on Oct 22, 2025

    @finagolfin
    Member

    Note that while cross-compiling some proportion of Testing tests has worked for a while now, long-standing SwiftPM bugs like swiftlang/swift-package-manager#8094 have broken cross-compiling this repo's tests to any platform, so the remaining steps here are blocked on those underlying bugs, which I'm told the new swift-build backend may soon fix. Instead, I have been occasionally natively building the trunk toolchain on Android in the Termux app then testing this repo, and with #1373 or an earlier patch, all tests passed.

  5. grynspan commented on Apr 18, 2026

    @grynspan
    ContributorAuthor

    @finagolfin @compnerd Any thoughts on how we can run our test suite automatically on Android as part of our GHA workflow suite? If we can do that and we can sort out instructions for at-desk testing, we can mark Android as fully supported I believe.

  6. compnerd commented on Apr 18, 2026

    @compnerd
    Member

    Yes, that is possible; https://github.com/compnerd/ds2 was running the tests on Android, so it is definitely possible to do in GHA.

  7. finagolfin commented on Apr 18, 2026

    @finagolfin
    Member

    There are potentially two separate issues with cross-compiling Testing tests for Android:

    1. We need to check if the recent swift-build switch in trunk SwiftPM fixed the problems with using macros, or if more work is needed in SwiftPM.
    2. Once a test runner is successfully produced, it should just work with the current official workflows, which @marcprux already has working with Testing, provided packages don't define their own macros and avoid that long-standing SwiftPM bug.

    We won't know if 2. works for sure till we fix 1., but the emulator testing probably works fine already.

  8. marcprux commented on Apr 18, 2026

    @marcprux

    We still can't cross-compile the Testing tests due to swiftlang/swift-package-manager#8094. I just tried again with 6.3.1 and got the expected failure:

    zap swift-android-sdk/swift-testing [android-checks] % ANDROID_SERIAL=emulator-5554 skip android test
    
    [0/1] Planning build
    Building for debugging...
    [0/21] Write sources
    [37/65] Write swift-version-27A8E6E6C94AF7AD.txt
    [38/65] Write sources
    [39/67] Compiling _TestingInternals Discovery.cpp
    …
    [784/791] Compiling TestingTests EventHandlingInteropTests.swift
    [785/791] Emitting module TestingTests
    error: Failed opening '/opt/src/github/swift-android-sdk/swift-testing/.build/aarch64-unknown-linux-android28/debug/index/store/v5/units/ABI.EncodedTestTests.swift.o-IOQ08LTW0GJI': No such file or directory
    [785/791] /opt/src/github/swift-android-sdk/swift-testing/.build/aarch64-unknown-linux-android28/debug/swift-testingPackageDiscoveredTests.derived/all-discovered-tests.swift
    Error: Error terminated(code: 1) running command: /Users/marc/Library/Developer/Toolchains/swift-6.3.1-RELEASE.xctoolchain/usr/bin/swift build --swift-sdk aarch64-unknown-linux-android28 --build-tests -Xswiftc -plugin-path -Xswiftc /Users/marc/Library/Developer/Toolchains/swift-6.3.1-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing -Xswiftc -DSKIP_BRIDGE -Xswiftc -DTARGET_OS_ANDROID
    

    For GHA CI, you can activate Android testing by just turning on enable_android_sdk_checks: true (in addition to enable_android_sdk_build: true, which is already enabled), but as expected, it also fails in my attempt: swift-android-sdk#1

    To be clear, tests that use Testing do work fine on Android (provided the package under test does not define its own additional macros), but Testing itself cannot be tested in Android due to this issue. I hope it gets fixed someday!

  9. finagolfin commented on Jun 14, 2026

    @finagolfin
    Member

    It looks like this works with the switch to swift-build in 6.4 and the tests will be set up in #1745, once a few last tweaks are made. I don't know what "Set up team workstations or VMs" refers to, but this support will be ready soon.

  10. grynspan commented on Jun 15, 2026

    @grynspan
    ContributorAuthor

    It means code owners have some way to reliably run tests on Android at-desk (presumably in an emulator/simulator environment). Instructions for setting up such an environment can go in a new Documentation/Android.md file.

  11. finagolfin commented on Jul 17, 2026

    @finagolfin
    Member

    All that remains is the doc Jonathan asked for with the upcoming 6.4 release, as everything now works with the 6.4 snapshots, will submit a doc pull for that before closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

android🤖 Android supportenhancementNew feature or requesthelp wantedExtra attention is needednew-platform-support🌟 Boldly go where no `#expect` macro has gone before (to a new platform)

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions