{"id":28435162,"url":"https://github.com/skiptools/swift-android-action","last_synced_at":"2025-09-12T18:05:15.843Z","repository":{"id":255754153,"uuid":"853545400","full_name":"skiptools/swift-android-action","owner":"skiptools","description":"GitHub action to build and run Swift package tests on an Android emulator","archived":false,"fork":false,"pushed_at":"2025-08-30T16:03:36.000Z","size":278,"stargazers_count":20,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-30T17:37:37.336Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skiptools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-06T21:57:51.000Z","updated_at":"2025-08-30T16:03:40.000Z","dependencies_parsed_at":"2025-01-04T17:23:57.523Z","dependency_job_id":"d0b20618-25b9-44dc-b054-b85da9b0ddf8","html_url":"https://github.com/skiptools/swift-android-action","commit_stats":null,"previous_names":["swift-android-sdk/swift-test","skiptools/swift-android-action","swift-android-sdk/swift-android-action"],"tags_count":39,"template":false,"template_full_name":null,"purl":"pkg:github/skiptools/swift-android-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skiptools%2Fswift-android-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skiptools%2Fswift-android-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skiptools%2Fswift-android-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skiptools%2Fswift-android-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skiptools","download_url":"https://codeload.github.com/skiptools/swift-android-action/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skiptools%2Fswift-android-action/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273790317,"owners_count":25168669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-05T20:06:49.762Z","updated_at":"2025-09-05T17:12:17.642Z","avatar_url":"https://github.com/skiptools.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift Android native cross-compiler and test runner action\n\nThis GitHub action will build and run Swift package tests on an Android emulator.\nThis uses the [swift-android-toolchain](https://github.com/skiptools/swift-android-toolchain)\nproject to provide a cross-compiler for building\nSwift natively for Android on a Linux or macOS host.\n\nAfter building the package, it will run the SwiftPM\ntest targets on an Android emulator (which is provided by the\n[Android Emulator Runner action](https://github.com/marketplace/actions/android-emulator-runner)).\nTo build the package for Android without running the tests\n(which is considerably faster), set the `run-tests` option to `false`.\n\nYou can add this action to your Swift CI workflow from the\n[GitHub Marketplace](https://github.com/marketplace/actions/swift-android-action),\nor you can manually create a workflow by adding a\n`.github/workflows/swift-ci.yml` file to your project.\nThis sample action will run your Swift package's test cases\non a host macOS machine, as well as on an Android emulator\nand an iOS simulator.\n\n## Example\n\nThe following `ci.yml` workflow will check out the current repository and test the Swift package on Linux and Android:\n\n```yml\nname: ci\non:\n  push:\n    branches:\n      - '*'\n  workflow_dispatch:\n  pull_request:\n    branches:\n      - '*'\njobs:\n  linux-android:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - name: \"Test Swift Package on Linux\"\n        run: swift test\n      - name: \"Test Swift Package on Android\"\n        uses: skiptools/swift-android-action@v2\n```\n\n\n## Configuration\n\nThe following configuration options can be passed to the workflow. For example, to specify the version of Swift you want to use for building and testing, you can use the `swift-version` parameter like so:\n\n```yml\njobs:\n  linux-android:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - name: \"Test Swift Package on Linux\"\n        run: swift test\n      - name: \"Test Swift Package on Android\"\n        uses: skiptools/swift-android-action@v2\n        with:\n          swift-version: 6.1\n```\n\n### Swift Versions\n\nThe `swift-version` input can be set to a specific version number (e.g., \"6.0.3\" or \"6.1.1\").\nA shortened version like \"6.0\" or \"6.1\" will use the latest [release](https://github.com/skiptools/swift-android-toolchain/releases),\nwhich may be a pre-release build.\n\n\u003e [!NOTE]\n\u003e The SDK that is installed is currently the unofficial de-facto Android SDK created from\n\u003e the [swift-android-sdk](https://github.com/swift-android-sdk/swift-android-sdk) fork.\n\u003e As the official Android WG is [formed](https://www.swift.org/android-workgroup/),\n\u003e we anticipate the release of an official Android SDK, at which time this action will\n\u003e transition to using the authoritative SDK bundle.\n\nSnapshots can be specified with their full name, like `6.2-DEVELOPMENT-SNAPSHOT-2025-08-28-a`,\nor the most recent snapshot/nightly build can be specified with `nightly-6.2`.\n\n### Configuration Options\n\n| Parameter | Description | Default  |\n|-----|-----|-----|\n| swift-version | The version of the Swift toolchain to use | 6.1 |\n| ndk-version | The version of the Android NDK to use | \u003cdefault\u003e |\n| package-path | The folder where the swift package is checked out | . |\n| swift-configuration | Whether to build with debug or release configuration | debug |\n| swift-build-flags | Additional flags to pass to the swift build command |  |\n| swift-test-flags | Additional flags to pass to the swift test command |  |\n| installed-sdk | The name of a pre-installed Swift SDK to use |  |\n| installed-swift | The path to a pre-installed host Swift toolchain |  |\n| test-env | Test environment variables key=value |  |\n| build-package | Whether to build the Swit package | true |\n| build-tests | Whether to build the package tests or just the sources | true |\n| run-tests | Whether to run the tests or just perform the build | true |\n| copy-files | Additional files to copy to emulator for testing | |\n| android-emulator-test-folder | Emulator folder where tests are copied | /data/local/tmp/android-xctest |\n| android-api-level | The API level of the Android emulator to run against | 30 |\n| android-channel | SDK component channel: stable, beta, dev, canary | stable |\n| android-profile | Hardware profile used for creating the AVD | pixel |\n| android-target | Target of the system image | aosp_atd |\n| android-cores | Number of cores to use for the emulator | 2 |\n| android-emulator-options | Options to pass to the Android emulator | -no-window … |\n| android-emulator-boot-timeout | Emulator boot timeout in seconds | 600 |\n\n### Platform Support\n\nThis action can be run on any of the GitHub `ubuntu-*` and `macos-*` [runner images](https://github.com/actions/runner-images). However, due to the inability of macOS on ARM to run nested virtualization ([issue](https://github.com/ReactiveCircus/android-emulator-runner/issues/350)), the Android emulator cannot be run on these platforms, and so running on any macOS image that uses ARM (including `macos-14` and `macos-15`) requires disabling tests with `run-tests: false`. Running tests are supported on `macos-13`, as well as the large Intel macOS images like `macos-14-large` and `macos-15-large`.\n\nAn example of disabling running tests on ARM macOS images is:\n\n```yml\njobs:\n  macos-android:\n    runs-on: macos-15\n    steps:\n      - uses: actions/checkout@v4\n      - name: \"Test Swift Package on macOS\"\n        run: swift test\n      - name: \"Build Swift Package on Android\"\n        uses: skiptools/swift-android-action@v2\n        with:\n          run-tests: false\n```\n\n### Test Resources and Environment Variables\n\nUnit tests sometimes need to load local resources, such as configuration\nfiles and mocking or parsing inputs. This is typically handled\nusing [Bundle.module](https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package),\nwhich will be automatically copied up to the Android emulator when\ntesting and so should work transparently.\n\nHowever, in some cases a test script may expect a specific set\nof local files to be present, such as when a unit test needs to\nexamine the contents of the source code itself. In these cases,\nyou can use the `copy-files` input parameter to specify local files\nto copy up to the emulator when running.\n\nSimilarly, some test cases may expect a certain environment to be set.\nThis can be accomplished using the `test-env` parameter, which\nis a space separated list of key=value pairs of environment\nvariables to set when running the tests.\n\nFor example:\n\n```yml\n  - name: Test Android Package\n    uses: skiptools/swift-android-action@v2\n    with:\n      copy-files: Tests\n      test-env: TEST_WORKSPACE=1\n```\n\n### Installing without Building\n\nYou may wish to use this action to just install the toolchain and\nAndroid SDK without performing the build. For example, if you\nwish to build multiple packages consecutively, and don't need to\nrun the test cases. In this case, you can set the\n`build-package` input to false, and then use the action's\n`swift-build` output to get the complete `swift build` command\nwith all the appropriate paths and arguments to build using the\nSDK.\n\nFor example:\n\n```yml\n  - name: Setup Toolchain\n    id: setup-toolchain\n    uses: skiptools/swift-android-action@v2\n    with:\n      # just set up the toolchain but don't build anything\n      build-package: false\n  - name: Checkout apple/swift-numerics\n    uses: actions/checkout@v4\n  - name: Build Package With Toolchain\n    run: |\n      # build twice, once with debug and once with release\n      ${{ steps.setup-toolchain.outputs.swift-build }} -c debug\n      ls .build/${{ steps.setup-toolchain.outputs.swift-sdk }}/debug\n      ${{ steps.setup-toolchain.outputs.swift-build }} -c release\n      ls .build/${{ steps.setup-toolchain.outputs.swift-sdk }}/release\n```\n\nThe actual `swift-build` command will vary between operating systems\nand architectures. For example, on Ubuntu 24.04, it might be:\n\n```\n/home/runner/swift/toolchains/swift-6.1-RELEASE/usr/bin/swift build --swift-sdk x86_64-unknown-linux-android24\n```\n\nwhile on macOS-15 it will be:\n\n```\n/Users/runner/Library/Developer/Toolchains/swift-6.1-RELEASE.xctoolchain/usr/bin/swift build --swift-sdk aarch64-unknown-linux-android24\n```\n\n\n## Complete Universal CI Example\n\nFollowing is an example of a `ci.yml` workflow that checks out and tests a Swift package on each of macOS, iOS, Linux, Android, and Windows.\n\n```yml\nname: swift-algorithms ci\non:\n  push:\n    branches:\n      - '*'\n  workflow_dispatch:\n  pull_request:\n    branches:\n      - '*'\njobs:\n  linux-android:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - name: \"Test Swift Package on Linux\"\n        run: swift test\n      - name: \"Test Swift Package on Android\"\n        uses: skiptools/swift-android-action@v2\n  macos-ios:\n    runs-on: macos-latest\n    steps:\n      - uses: actions/checkout@v4\n      - name: \"Test Swift Package on macOS\"\n        run: swift test\n      - name: \"Test Swift Package on iOS\"\n        run: xcodebuild test -sdk \"iphonesimulator\" -destination \"platform=iOS Simulator,name=$(xcrun simctl list devices --json | jq -r '.devices | to_entries[] | .value[] | select(.availability == \"(available)\" or .isAvailable == true) | .name' | grep -E '^iPhone [0-9]+$' | sort -V | tail -n 1)\" -scheme \"$(xcodebuild -list -json | jq -r '.workspace.schemes[-1]')\"\n  windows:\n    runs-on: windows-latest\n    steps:\n      - uses: actions/checkout@v4\n      - name: \"Setup Swift on Windows\"\n        uses: compnerd/gha-setup-swift@main\n        with:\n          branch: swift-6.1-release\n          tag: 6.1-RELEASE\n      - name: \"Test Swift Package on Windows\"\n        run: swift test\n\n```\n\nFor an example of this workflow in action, see a run history\nfor the [swift-sqlite](https://github.com/swift-android-sdk/swift-sqlite/actions) package.\n\n## Adding Android Support to existing Packages\n\nRecommendations for adding Android compatibility to\nexisting Swift packages can be found at\n[Bringing Swift Packages to Android](https://skip.tools/blog/android-native-swift-packages/).\n\n## Releasing new versions\n\nTo create a new release, make a new tag (like 2.0.2),\nand then update the symbolic major v2 tag with:\n\n```\ngit tag v2.0.2 \u0026\u0026 git push --tags\ngit tag -fa v2 -m \"Update v2 tag\" \u0026\u0026 git push origin v2 --force\ngh release create --generate-notes --latest\n```\n\n## Who is using the Swift Android Action?\n\nThese are some of the open-source projects using (or have used) the Swift Android Action:\n\n- [Alamofire](https://github.com/Alamofire/Alamofire/tree/master/.github/workflows)\n- [Bagbutik](https://github.com/MortenGregersen/Bagbutik/tree/main/.github/workflows)\n- [BigInt](https://github.com/attaswift/BigInt/tree/master/.github/workflows)\n- [CryptoSwift](https://github.com/krzyzanowskim/CryptoSwift/tree/main/.github/workflows)\n- [egeniq/app-remote-config](https://github.com/egeniq/app-remote-config/tree/main/.github/workflows)\n- [Forked](https://github.com/drewmccormack/Forked/tree/main/.github/workflows)\n- [GraphQL](https://github.com/GraphQLSwift/GraphQL/tree/main/.github/workflows)\n- [jose-swift](https://github.com/beatt83/jose-swift/tree/main/.github/workflows)\n- [MemoZ](https://github.com/marcprux/MemoZ/tree/main/.github/workflows)\n- [PromiseKit](https://github.com/mxcl/PromiseKit/tree/master/.github/workflows)\n- [ReactiveKit](https://github.com/DeclarativeHub/ReactiveKit/tree/master/.github/workflows)\n- [Skip](https://github.com/skiptools/actions/tree/main/.github/workflows)\n- [soto-core](https://github.com/soto-project/soto-core/tree/main/.github/workflows)\n- [SQLite.swift](https://github.com/stephencelis/SQLite.swift/tree/master/.github/workflows)\n- [supabase-swift](https://github.com/supabase/supabase-swift/tree/main/.github/workflows)\n- [swift-android-native](https://github.com/skiptools/swift-android-native/tree/main/.github/workflows)\n- [SwiftCBOR](https://github.com/valpackett/SwiftCBOR/tree/master/.github/workflows)\n- [SwiftDraw](https://github.com/swhitty/SwiftDraw/tree/main/.github/workflows)\n- [swift-fakes](https://github.com/Quick/swift-fakes/tree/main/.github/workflows)\n- [SwiftGodot](https://github.com/migueldeicaza/SwiftGodot/tree/main/.github/workflows)\n- [swift-issue-reporting](https://github.com/pointfreeco/swift-issue-reporting/tree/main/.github/workflows)\n- [swift-jni](https://github.com/skiptools/swift-jni/tree/main/.github/workflows)\n- [swift-macro-testing](https://github.com/pointfreeco/swift-macro-testing/tree/main/.github/workflows)\n- [swift-png](https://github.com/tayloraswift/swift-png/tree/master/.github/workflows)\n- [swift-snapshot-testing](https://github.com/pointfreeco/swift-snapshot-testing/tree/main/.github/workflows)\n- [swift-sqlcipher](https://github.com/skiptools/swift-sqlcipher/tree/main/.github/workflows)\n- [SwifterSwift](https://github.com/SwifterSwift/SwifterSwift/tree/master/.github/workflows)\n- [universal](https://github.com/marcprux/universal/tree/main/.github/workflows)\n- [vapor/ci](https://github.com/vapor/ci/tree/main/.github/workflows)\n- [WasmKit](https://github.com/swiftwasm/WasmKit/tree/main/.github/workflows)\n- [Yams](https://github.com/jpsim/Yams/tree/main/.github/workflows)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskiptools%2Fswift-android-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskiptools%2Fswift-android-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskiptools%2Fswift-android-action/lists"}