From e7d782b486832b6aff7deaa0b265d6ba1074a23b Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Wed, 22 Oct 2025 13:38:43 -0400 Subject: [PATCH 1/6] Use swift_package_test.yml workflow for build --- .github/workflows/ci.yml | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ced64a..287ba02 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,6 +75,7 @@ jobs: sudo rm -rf "$AGENT_TOOLSDIRECTORY" - name: Install Prerequisites + if: false run: | if [[ "${RUNNER_OS}" == "Linux" ]]; then # libcurl4-openssl-dev needed for host toolchain @@ -83,6 +84,7 @@ jobs: # swiftly install instructions from https://www.swift.org/install/linux/ - name: Install Swiftly + if: false run: | if [[ "${RUNNER_OS}" == "macOS" ]]; then curl -O https://download.swift.org/swiftly/darwin/swiftly.pkg && \ @@ -103,15 +105,19 @@ jobs: echo "${SWIFTLY_BIN_DIR}" >> "${GITHUB_PATH}" - name: Install Swift Host Toolchain + if: false run: swiftly install --use "${SWIFT_TOOLCHAIN_VERSION}" - name: Install Swift SDK for Android + if: false run: swift sdk install https://download.swift.org/development/android-sdk/${SWIFT_ANDROID_SDK_VERSION}-a/${SWIFT_ANDROID_SDK_VERSION}-a_android-0.1.artifactbundle.tar.gz --checksum ${SWIFT_ANDROID_SDK_CHECKSUM} - name: List Swift SDKs + if: false run: swift sdk list - name: Install Android NDK + if: false run: | mkdir ~/android-ndk cd ~/android-ndk @@ -120,6 +126,7 @@ jobs: echo "ANDROID_NDK_HOME=${PWD}/android-ndk-${ANDROID_NDK_VERSION}" >> $GITHUB_ENV - name: Setup Android Environment + if: false run: | echo "$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/${{ env.ANDROID_BUILD_TOOLS_VERSION }}" >> $GITHUB_PATH # needed for Linux or else the emulator will be created in @@ -129,16 +136,26 @@ jobs: fi - name: Setup Swift SDK for Android + if: false run: | cd ~/Library/org.swift.swiftpm || cd ${XDG_CONFIG_HOME}/swiftpm || cd ~/.local/swiftpm || cd ~/.swiftpm ./swift-sdks/${SWIFT_ANDROID_SDK_VERSION}-a-android-0.1.artifactbundle/swift-android/scripts/setup-android-sdk.sh - - name: Build Swift Executable for Android + - name: Create Swift Package + run: | + swift package init --name hello --type executable + + - name: Build Package for Android + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main + with: + enable_android_sdk_build: true + #android_ndk_version: ${ANDROID_NDK_VERSION} + enable_linux_checks: false + enable_macos_checks: false + enable_windows_checks: false + + - name: Check Swift Package run: | - mkdir hello - cd hello - swiftly run swift package init --type executable - swiftly run swift build --swift-sdk "${ANDROID_EMULATOR_ARCH_TRIPLE}-unknown-linux-android${ANDROID_API}" --static-swift-stdlib file .build/debug/hello - name: Enable KVM @@ -190,7 +207,6 @@ jobs: - name: Push Swift Executable to Android Emulator run: | - cd hello adb push .build/debug/hello /data/local/tmp adb push $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/*/sysroot/usr/lib/${ANDROID_EMULATOR_ARCH_TRIPLE}-linux-android/libc++_shared.so /data/local/tmp/ From ebd4268baa25257a08701ba1dba15e9c78d83a9c Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Wed, 22 Oct 2025 13:42:21 -0400 Subject: [PATCH 2/6] Use install script to install Android SDK --- .github/workflows/ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 287ba02..7387d4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -146,13 +146,10 @@ jobs: swift package init --name hello --type executable - name: Build Package for Android - uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main - with: - enable_android_sdk_build: true - #android_ndk_version: ${ANDROID_NDK_VERSION} - enable_linux_checks: false - enable_macos_checks: false - enable_windows_checks: false + run: | + #curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ + curl -s --retry 3 https://raw.githubusercontent.com/swift-android-sdk/github-workflows/refs/heads/android-workflow/.github/workflows/scripts/install-and-build-with-sdk.sh | \ + bash -s -- --android --flags="$BUILD_FLAGS" --build-command="${{ inputs.android_sdk_build_command }}" --android-sdk-triple="${{ inputs.android_sdk_triple }}" --android-ndk-version="${{ inputs.android_ndk_version }}" ${{ matrix.swift_version }} - name: Check Swift Package run: | From ff77c9bab6bf943a577b3646b4c62c2aaaebbcef Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Wed, 22 Oct 2025 13:47:08 -0400 Subject: [PATCH 3/6] Fix install script arguments --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7387d4f..3036333 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,7 @@ jobs: strategy: fail-fast: false matrix: + swift_version: ['nightly-main'] include: - name: 'macOS 15 X64 API 28' os: 'macos-15-intel' @@ -149,7 +150,7 @@ jobs: run: | #curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ curl -s --retry 3 https://raw.githubusercontent.com/swift-android-sdk/github-workflows/refs/heads/android-workflow/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --android --flags="$BUILD_FLAGS" --build-command="${{ inputs.android_sdk_build_command }}" --android-sdk-triple="${{ inputs.android_sdk_triple }}" --android-ndk-version="${{ inputs.android_ndk_version }}" ${{ matrix.swift_version }} + bash -s -- --android --flags="$BUILD_FLAGS" --android-sdk-triple="${{ inputs.android_sdk_triple }}" --android-ndk-version="${ANDROID_NDK_VERSION}" ${{ matrix.swift_version }} - name: Check Swift Package run: | From 101b3fdfcf91a4243909e1b3f31d813221192158 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Wed, 22 Oct 2025 14:04:53 -0400 Subject: [PATCH 4/6] Fix install script arguments --- .github/workflows/ci.yml | 94 ++++++---------------------------------- 1 file changed, 13 insertions(+), 81 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3036333..184d785 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - swift_version: ['nightly-main'] + #swift_version: ['nightly-main'] include: - name: 'macOS 15 X64 API 28' os: 'macos-15-intel' @@ -63,9 +63,8 @@ jobs: ANDROID_PROFILE: "Nexus 10" ANDROID_CHANNEL: "3" ANDROID_NDK_VERSION: "r27d" - SWIFT_TOOLCHAIN_VERSION: "swift-DEVELOPMENT-SNAPSHOT-2025-10-16" - SWIFT_ANDROID_SDK_VERSION: "swift-DEVELOPMENT-SNAPSHOT-2025-10-16" - SWIFT_ANDROID_SDK_CHECKSUM: "451844c232cf1fa02c52431084ed3dc27a42d103635c6fa71bae8d66adba2500" + SWIFT_VERSION: "nightly-main" + steps: - name: Free Disk Space if: runner.os == 'Linux' @@ -75,73 +74,6 @@ jobs: sudo rm -rf "/usr/local/share/boost" sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - name: Install Prerequisites - if: false - run: | - if [[ "${RUNNER_OS}" == "Linux" ]]; then - # libcurl4-openssl-dev needed for host toolchain - sudo apt-get -y install libcurl4-openssl-dev - fi - - # swiftly install instructions from https://www.swift.org/install/linux/ - - name: Install Swiftly - if: false - run: | - if [[ "${RUNNER_OS}" == "macOS" ]]; then - curl -O https://download.swift.org/swiftly/darwin/swiftly.pkg && \ - installer -pkg swiftly.pkg -target CurrentUserHomeDirectory && \ - ~/.swiftly/bin/swiftly init --quiet-shell-followup && \ - . "${SWIFTLY_HOME_DIR:-$HOME/.swiftly}/env.sh" && \ - hash -r - elif [[ "${RUNNER_OS}" == "Linux" ]]; then - curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz && \ - tar zxf swiftly-$(uname -m).tar.gz && \ - ./swiftly init --quiet-shell-followup && \ - . "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh" && \ - hash -r - else - echo "Error: unsupported OS: ${RUNNER_OS}" - exit 1 - fi - echo "${SWIFTLY_BIN_DIR}" >> "${GITHUB_PATH}" - - - name: Install Swift Host Toolchain - if: false - run: swiftly install --use "${SWIFT_TOOLCHAIN_VERSION}" - - - name: Install Swift SDK for Android - if: false - run: swift sdk install https://download.swift.org/development/android-sdk/${SWIFT_ANDROID_SDK_VERSION}-a/${SWIFT_ANDROID_SDK_VERSION}-a_android-0.1.artifactbundle.tar.gz --checksum ${SWIFT_ANDROID_SDK_CHECKSUM} - - - name: List Swift SDKs - if: false - run: swift sdk list - - - name: Install Android NDK - if: false - run: | - mkdir ~/android-ndk - cd ~/android-ndk - curl -fsSLO https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-$(uname -s).zip - unzip -q android-ndk-${ANDROID_NDK_VERSION}-*.zip - echo "ANDROID_NDK_HOME=${PWD}/android-ndk-${ANDROID_NDK_VERSION}" >> $GITHUB_ENV - - - name: Setup Android Environment - if: false - run: | - echo "$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/${{ env.ANDROID_BUILD_TOOLS_VERSION }}" >> $GITHUB_PATH - # needed for Linux or else the emulator will be created in - # ~/.android/avd but it will be sought in ~/.config/.android/avd - if [[ "${RUNNER_OS}" == "Linux" ]]; then - echo "ANDROID_AVD_HOME=${XDG_CONFIG_HOME:-$HOME}/.android/avd" >> $GITHUB_ENV - fi - - - name: Setup Swift SDK for Android - if: false - run: | - cd ~/Library/org.swift.swiftpm || cd ${XDG_CONFIG_HOME}/swiftpm || cd ~/.local/swiftpm || cd ~/.swiftpm - ./swift-sdks/${SWIFT_ANDROID_SDK_VERSION}-a-android-0.1.artifactbundle/swift-android/scripts/setup-android-sdk.sh - - name: Create Swift Package run: | swift package init --name hello --type executable @@ -150,7 +82,7 @@ jobs: run: | #curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ curl -s --retry 3 https://raw.githubusercontent.com/swift-android-sdk/github-workflows/refs/heads/android-workflow/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --android --flags="$BUILD_FLAGS" --android-sdk-triple="${{ inputs.android_sdk_triple }}" --android-ndk-version="${ANDROID_NDK_VERSION}" ${{ matrix.swift_version }} + bash -s -- --android --flags="$BUILD_FLAGS" --android-sdk-triple="${{ inputs.android_sdk_triple }}" --android-ndk-version="${ANDROID_NDK_VERSION}" ${SWIFT_VERSION} - name: Check Swift Package run: | @@ -165,6 +97,15 @@ jobs: sudo udevadm trigger --name-match=kvm fi + - name: Setup Android Environment + run: | + echo "$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/${{ env.ANDROID_BUILD_TOOLS_VERSION }}" >> $GITHUB_PATH + # needed for Linux or else the emulator will be created in + # ~/.android/avd but it will be sought in ~/.config/.android/avd + if [[ "${RUNNER_OS}" == "Linux" ]]; then + echo "ANDROID_AVD_HOME=${XDG_CONFIG_HOME:-$HOME}/.android/avd" >> $GITHUB_ENV + fi + - name: Android SDKs - setup environment run: yes y | sdkmanager --licenses > /dev/null @@ -180,12 +121,6 @@ jobs: - name: Android Emulator - Create run: avdmanager --verbose create avd --force -n "${ANDROID_EMULATOR_NAME}" --device "${ANDROID_PROFILE}" --abi "${ANDROID_TARGET}/${ANDROID_EMULATOR_ARCH}" --package "system-images;android-${ANDROID_API};${ANDROID_TARGET};${ANDROID_EMULATOR_ARCH}" --sdcard 512M - #- name: Android - Find AVDs - # run: find ~/ -type d -name '*.avd' - - #- name: Android - List AVDs - # run: emulator -list-avds - - name: Android - Boot run: nohup emulator -memory 4096 -avd "${ANDROID_EMULATOR_NAME}" -wipe-data -no-window -accel off -no-accel -gpu "${ANDROID_EMULATOR_GPU}" -no-snapshot -noaudio -no-boot-anim & @@ -196,9 +131,6 @@ jobs: - name: Pause briefly run: sleep 30 - #- name: ADB Press Power Button - # run: adb shell input keyevent 82 - - name: Check Android Emulator run: | adb shell 'echo Hello Android!' From 38fd9db8ae731221e479f1e3203431c9712b5208 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Wed, 22 Oct 2025 14:17:49 -0400 Subject: [PATCH 5/6] Fix install script arguments --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 184d785..fa45641 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,7 @@ jobs: ANDROID_CHANNEL: "3" ANDROID_NDK_VERSION: "r27d" SWIFT_VERSION: "nightly-main" + BUILD_FLAGS: "--static-swift-stdlib" steps: - name: Free Disk Space @@ -82,7 +83,7 @@ jobs: run: | #curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ curl -s --retry 3 https://raw.githubusercontent.com/swift-android-sdk/github-workflows/refs/heads/android-workflow/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --android --flags="$BUILD_FLAGS" --android-sdk-triple="${{ inputs.android_sdk_triple }}" --android-ndk-version="${ANDROID_NDK_VERSION}" ${SWIFT_VERSION} + bash -s -- --android --flags="$BUILD_FLAGS" --android-sdk-triple="${ANDROID_EMULATOR_ARCH_TRIPLE}-unknown-linux-android${ANDROID_API}" --android-ndk-version="${ANDROID_NDK_VERSION}" ${SWIFT_VERSION} - name: Check Swift Package run: | From 29b554edb15b22d9d745908da3a73d48294df8f5 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Wed, 22 Oct 2025 14:46:55 -0400 Subject: [PATCH 6/6] Note that install-and-build-with-sdk.sh does not support macOS --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa45641..c644514 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,9 +81,11 @@ jobs: - name: Build Package for Android run: | - #curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - curl -s --retry 3 https://raw.githubusercontent.com/swift-android-sdk/github-workflows/refs/heads/android-workflow/.github/workflows/scripts/install-and-build-with-sdk.sh | \ - bash -s -- --android --flags="$BUILD_FLAGS" --android-sdk-triple="${ANDROID_EMULATOR_ARCH_TRIPLE}-unknown-linux-android${ANDROID_API}" --android-ndk-version="${ANDROID_NDK_VERSION}" ${SWIFT_VERSION} + # TODO: the install-and-build-with-sdk.sh script does not yet + # support macOS, so use swiftly to install and setup the toolchain… + #curl -s --retry 3 https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/install-and-build-with-sdk.sh | \ + curl -s --retry 3 https://raw.githubusercontent.com/swift-android-sdk/github-workflows/refs/heads/android-workflow/.github/workflows/scripts/install-and-build-with-sdk.sh | \ + bash -s -- --android --flags="$BUILD_FLAGS" --android-sdk-triple="${ANDROID_EMULATOR_ARCH_TRIPLE}-unknown-linux-android${ANDROID_API}" --android-ndk-version="${ANDROID_NDK_VERSION}" ${SWIFT_VERSION} - name: Check Swift Package run: |