New
Apps 6,265Makers 6,244This week 13
Promote your app−30%
2views in
the last 30 days

Swift-Build

GitHub Action for building and testing Swift packages across all platforms

Built with Claude Code

by brightdigit · Unclaimed · added Nov 3, 2026
no ratings0 comments

A comprehensive GitHub Action for building and testing Swift packages across all platforms with intelligent caching and zero-config setup.

Note

:open_book: Learn how swift-build works in this blog post.

📋 Table of Contents

✨ Why Choose This Action?

🚀 Zero Configuration - Works out of the box with just a scheme parameter ⚡ Intelligent Caching - Platform-specific caching strategies for maximum performance 🌍 Complete Platform Coverage - Ubuntu (Swift 5.9-6.2) + macOS (iOS, watchOS, tvOS, visionOS, macOS) + Windows (Swift 6.1+) + Android (Swift 6.1+) 🎯 Optimized Workflows - Purpose-built for modern Swift CI/CD pipelines 📦 Real-World Proven - Used by 25+ open source Swift packages including SyndiKit, DataThespian, and more

⚙️ Configuration Reference

Parameters

Parameter Description Default Example Valid Values Used By
scheme The scheme to build and test Auto-calculated MyPackage-Package Any valid scheme name Xcode builds only - Optional. When omitted on Apple-platform builds (iOS, watchOS, tvOS, visionOS, macOS) it is auto-derived from the Swift package: a single product uses the product name; multiple products use <PackageName>-Package. Provide explicitly to override. Not needed for SwiftPM builds (Ubuntu/macOS)
working-directory Directory containing the Swift package . ./MyPackage Any valid directory path All platforms - SwiftPM (Ubuntu/macOS) and Xcode builds
type Build type null ios ios, watchos, visionos, tvos, macos, android Platform selection - Apple platforms use xcodebuild, android uses Swift Android SDK. When null, uses SwiftPM (swift build/test). Note: Android is auto-detected when any android-* parameter is set (explicit type: android not required)
xcode Xcode version path for Apple platforms System default /Applications/Xcode_15.4.app Any Xcode.app path Xcode builds only - iOS, watchOS, tvOS, visionOS, macOS simulator testing
deviceName Simulator device name null iPhone 15 Any available simulator Xcode builds only - Required when type is specified (except macos)
osVersion Simulator OS version null 17.5 Compatible OS version Xcode builds only - Required when type is specified (except macos)
download-platform Download platform if not available false true true, false Xcode builds only - iOS, watchOS, tvOS, visionOS simulator testing
build-only Build without running tests false true true, false All platforms - SwiftPM (Ubuntu/macOS/Windows) and Xcode builds
windows-swift-version Swift version for Windows toolchain null swift-6.1-release swift-6.0-release, swift-6.1-release, swift-6.2-branch Windows builds only - Maps to swift-version parameter in compnerd/gha-setup-swift
windows-swift-build Swift build identifier for Windows null 6.1-RELEASE 6.1-RELEASE, 6.2-DEVELOPMENT-SNAPSHOT-2025-09-06-a Windows builds only - Maps to swift-build parameter in compnerd/gha-setup-swift
android-swift-version Swift version for Android SDK 6.2 nightly-main Swift versions, snapshots, or nightly-main Android builds only - Auto-detects Android build. Maps to swift-version in skiptools/swift-android-action
android-api-level Android emulator API level 28 31 28, 29, 30, 31, 33, 34 Android builds only - Auto-detects Android build. Used with android-run-tests: true
android-ndk-version Android NDK version Action default 26.1.10909125 Any valid NDK version Android builds only - Auto-detects Android build
android-run-tests Run tests on Android emulator true false true, false Android builds only - Auto-detects Android build. Must be false on ARM macOS runners (no nested virtualization support)
android-swift-build-flags Additional Swift build flags for Android null -v Any valid Swift build flags Android builds only - Auto-detects Android build
android-swift-test-flags Additional Swift test flags for Android null --parallel Any valid Swift test flags Android builds only - Auto-detects Android build. Used with android-run-tests: true
android-emulator-boot-timeout Emulator boot timeout (seconds) 600 900 Any positive integer Android builds only - Auto-detects Android build. Used with android-run-tests: true
android-copy-files Additional files to copy to emulator for testing null Tests/Resources/ File paths or directories (space-separated) Android builds only - Auto-detects Android build. Used with android-run-tests: true. Copies test resources, data files, or configurations to emulator before running tests
android-sdk-url Custom Android Swift SDK artifactbundle URL null https://download.swift.org/swift-6.4.x-branch/android-sdk/.../<snapshot>_android.artifactbundle.tar.gz Any artifactbundle URL Android builds only - Passed to custom-sdk-url in skiptools/swift-android-action. Requires android-sdk-id. Use to target a nightly/snapshot Android SDK the android-swift-version path can't resolve
android-sdk-id Identifier for the custom Android SDK null swift-6.4.x-DEVELOPMENT-SNAPSHOT-2026-06-15-a_android The swift sdk id the bundle registers under Android builds only - Maps to custom-sdk-id. Required alongside android-sdk-url. Must match the id shown by swift sdk list after the bundle installs (a common source of misconfiguration)
android-sdk-target Swift SDK build triple for the custom Android SDK aarch64-unknown-linux-android28 (when android-sdk-url set) x86_64-unknown-linux-android28 Any registered SDK triple Android builds only - Maps to installed-sdk (the --swift-sdk <triple> target). swift-android-action requires a non-empty value alongside a custom SDK or it exits 1. Override if the bundle registers a different triple (check swift sdk configure --show-configuration)
wasmtime-version Optional Wasmtime runtime fallback for Wasm test execution Empty (uses WasmKit) 27.0.0, 26.0.0 Specific version (X.Y.Z format) or empty Wasm builds only - Default: WasmKit runtime (bundled with Swift 6.2.3+, no downloads). Specify a specific version to use Wasmtime fallback. Note: latest is no longer supported - use specific version numbers. Auto-cached per version to avoid ~500MB download when using Wasmtime
wasm-swift-flags Additional Swift compiler/linker flags for Wasm builds null -Xcc -D_WASI_EMULATED_SIGNAL -Xlinker -lwasi-emulated-signal Any valid Swift compiler flags Wasm builds only - Required for most projects using Foundation/CoreFoundation. Configures WASI emulation and memory limits. See Wasm Compiler Flags Configuration for common patterns
wasm-sdk-url Custom Wasm SDK artifactbundle URL null https://download.swift.org/swift-6.4.x-branch/wasm-sdk/.../<snapshot>_wasm.artifactbundle.tar.gz Any artifactbundle URL Wasm builds only - Overrides the derived download.swift.org -RELEASE URL; the --swift-sdk selector is derived from the bundle filename. Use for nightly/snapshot toolchains (no -RELEASE Wasm bundle exists). Pair with wasm-sdk-checksum
wasm-sdk-checksum SHA256 checksum for wasm-sdk-url null c014a0162de6... SHA256 hex string Wasm builds only - Passed to swift sdk install --checksum for verified installation. Recommended whenever wasm-sdk-url is set
skip-package-resolved Skip Package.resolved dependency pinning (allows floating dependency versions) false true true, false All platforms - When true, ignores Package.resolved and resolves dependencies dynamically. When false (default), enforces exact versions from Package.resolved (strict mode). Required when Package.resolved format is incompatible with Swift version (e.g., v3 format with Swift 5.9/5.10)
use-xcbeautify Enable xcbeautify for prettified xcodebuild output false true true, false Apple platforms only - macOS with type parameter specified
xcbeautify-renderer xcbeautify renderer for CI integration default github-actions default, github-actions, teamcity, azure-devops-pipelines Apple platforms only - Used when use-xcbeautify is true
xcargs Extra space-separated arguments appended to the xcodebuild invocation '' -scmProvider system Space-separated xcodebuild flags (no quoted values with spaces) Apple platforms only - Appended to xcodebuild build / xcodebuild test via env + argv array. Use -scmProvider system for private SSH SPM dependencies (Xcode's built-in libgit2 ignores ssh-agent / GIT_SSH_COMMAND). Scheme auto-calculation does not use xcargs — pass scheme explicitly if the xcodebuild -list fallback also needs -scmProvider system

Security note (custom SDK URLs): wasm-sdk-url and android-sdk-url download and install an SDK bundle from whatever host you point them at, so only use URLs from a trusted source (e.g. download.swift.org). For Wasm, prefer setting wasm-sdk-checksum so swift sdk install --checksum detects tampering or corruption.

Outputs

Output Description Example Values Usage
contains-code-coverage Whether this build contains code coverage data 'true', 'false' Returns 'true' for SwiftPM and Xcode builds with tests enabled. Returns 'false' for Wasm builds (not supported), Android builds (handled separately), Windows builds (not supported), and build-only mode. Use this to conditionally run coverage collection actions.
xcode-version The Xcode version used for the build '16.4', '26.5' Only populated on macOS runners. Empty for Ubuntu, Windows, Android, and Wasm.
swift-version The Swift version used for the build '6.2.3', '6.3' Populated for macOS, Ubuntu, Windows, and Wasm via swift --version. For Android, reflects the android-swift-version input (blank if not specified).

Usage Example:

- name: Build and Test
  id: build-step
  uses: brightdigit/swift-build@v1
  with:
    scheme: MyPackage-Package

- name: Generate Coverage
  if: steps.build-step.outputs.contains-code-coverage == 'true'
  uses: sersoft-gmbh/swift-coverage-action@v5

Parameter Combinations & Interactions

  • Ubuntu builds: Only working-directory is used (no scheme needed)
  • macOS SwiftPM builds: scheme, working-directory (no type specified)
  • Apple platform builds: Require type, optionally scheme (auto-calculated from the Swift package when omitted) and deviceName/osVersion
  • Windows builds: working-directory, windows-swift-version, windows-swift-build (no scheme needed)
  • Android builds: Auto-detected from any android-* parameter (e.g., android-swift-version, android-api-level). Explicit type: android optional but recommended for clarity
  • Custom Xcode: When xcode is specified, it overrides system default
  • Platform download: Only effective with Xcode versions

Default Behaviors

  • No type: Uses Swift Package Manager directly with swift command (works on Ubuntu, macOS, and Windows)
  • Simulator parameters: For iOS/watchOS/tvOS/visionOS, you must specify both deviceName and osVersion. macOS native (type: macos) does not require them.
  • No xcode: Uses system default Xcode installation
  • No working-directory: Operates in repository root
  • No Windows parameters: Windows builds require windows-swift-version and windows-swift-build to be specified

Build Tool Selection

  • Swift Package Manager: Uses swift build and swift test commands (Ubuntu, macOS, and Windows SwiftPM builds)
  • Xcode Build System: Uses xcodebuild command when type is specified (iOS, watchOS, tvOS, visionOS, macOS)
  • Swift Android SDK: Uses skiptools/swift-android-action when Android is detected (auto-detected from android-* parameters or explicit type: android)

Android Swift Version Support

The Android platform supports the following Swift versions through the Swift Android SDK:

  • Swift 6.2 (default) - Uses pre-official SDK from finagolfin/swift-android-sdk
  • Swift 6.1+ - Also supported via pre-official SDK (tested in production)
  • Swift 6.3+ snapshots - Uses official Swift SDK for Android from Swift.org
  • Development snapshots - nightly-main or nightly-6.3 tags for latest builds
  • Custom versions - Specify any Swift version, snapshot, or nightly build via android-swift-version parameter

Note: Swift 6.2 is the default. Earlier versions like 6.1 also work with the pre-official SDK. Swift 6.0 and earlier versions are not officially documented as supported.

Build-Only Mode

When build-only: true is specified:

  • SwiftPM builds: Uses swift build instead of swift build --build-tests + swift test
  • Xcode builds: Uses xcodebuild build instead of xcodebuild test
  • Code coverage: Not collected (coverage is only generated when tests are run)
  • Test compilation: Test targets are not compiled in build-only mode
  • Performance: Faster execution since tests are skipped
  • Use cases: Build validation, binary distribution, CI pipelines that separate build and test stages

xcbeautify Integration

swift-build includes optional integration with xcbeautify for enhanced xcodebuild output formatting and better CI integration.

When xcbeautify is Used

  • Platform: macOS only (requires Xcode toolchain)
  • Trigger: When use-xcbeautify: true AND type parameter is specified
  • Purpose: Provides human-friendly, colored output and better CI integration

xcbeautify Renderers

Renderer Description Best For
default Standard colored output Local development, general use
github-actions GitHub Actions integration GitHub Actions workflows
teamcity TeamCity service messages TeamCity CI/CD
azure-devops-pipelines Azure DevOps logging Azure DevOps Pipelines

xcbeautify Benefits

  • Enhanced Readability: Colored output with proper formatting
  • CI Integration: Platform-specific renderers for better log parsing
  • Error Highlighting: Clear identification of warnings and errors
  • Performance: Faster than alternatives like xcpretty
  • Modern Support: Works with new Xcode build system and parallel testing

Example Usage

# Basic xcbeautify usage
- uses: brightdigit/swift-build@v1
  with:
    scheme: MyApp
    type: ios
    deviceName: iPhone 15
    osVersion: '17.0'
    use-xcbeautify: true

# With specific renderer for GitHub Actions
- uses: brightdigit/swift-build@v1
  with:
    scheme: MyApp
    type: ios
    deviceName: iPhone 15
    osVersion: '17.0'
    use-xcbeautify: true
    xcbeautify-renderer: github-actions

🚀 Quick Start

Basic Usage Examples

The simplest possible configurations for common Swift package scenarios:

Minimal Swift Package Testing (Ubuntu)

name: Test Package
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    container: swift:6.1
    steps:
      - uses: actions/checkout@v6
      - uses: brightdigit/swift-build@v1
        with:
          scheme: MyPackage  # Just your package name

Minimal Swift Package Testing (macOS)

name: Test Package
on: [push, pull_request]

jobs:
  test:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v6
      - uses: brightdigit/swift-build@v1
        with:
          scheme: MyPackage-Package  # Standard SwiftPM scheme naming

Single-Target Package with Auto-Generated Scheme

name: Test Single Target
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    container: swift:6.1
    steps:
      - uses: actions/checkout@v6
      - uses: brightdigit/swift-build@v1
        with:
          scheme: MyLibrary  # Matches your target name in Package.swift

Multi-Target Package Testing

name: Test Multi-Target Package
on: [push, pull_request]

jobs:
  test:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v6
      - uses: brightdigit/swift-build@v1
        with:
          scheme: MyPackage-Package  # Tests all targets

Windows Swift Package Testing

name: Test Windows Package
on: [push, pull_request]

jobs:
  test:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v6
      - uses: brightdigit/swift-build@v1
        with:
          windows-swift-version: swift-6.1-release
          windows-swift-build: 6.1-RELEASE

Build-Only Mode (Skip Tests)

name: Build Validation
on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    container: swift:6.1
    steps:
      - uses: actions/checkout@v6
      - uses: brightdigit/swift-build@v1
        with:
          scheme: MyPackage
          build-only: true  # Only build, don't run tests

iOS Simulator Testing

name: Test iOS App
on: [push, pull_request]

jobs:
  test:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v6
      - uses: brightdigit/swift-build@v1
        with:
          scheme: YourApp
          type: ios
          deviceName: iPhone 15
          osVersion: '17.0'

iOS Testing with xcbeautify

name: Test iOS App with Enhanced Output
on: [push, pull_request]

jobs:
  test:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v6
      - uses: brightdigit/swift-build@v1
        with:
          scheme: YourApp
          type: ios
          deviceName: iPhone 15
          osVersion: '17.0'
          use-xcbeautify: true
          xcbeautify-renderer: github-actions

Multi-Platform Matrix Configurations

Complete Ubuntu Swift Version Matrix

name: Ubuntu Swift Testing
on: [push, pull_request]

jobs:
  test-ubuntu:
    strategy:
      matrix:

Description taken from the repository README.

Ratings

–
0 ratings
5 0
4 0
3 0
2 0
1 0

Rate this app

Sign in to rate

Comments 0

Sign in to comment

No comments yet.

Related apps

#swift · #ci · #github-actions