SophaxChat · Code Richard Metzner

13 · Making and shipping

.github/workflows/swift.yml

65 lines · YAML

name: Swift

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    name: Build SophaxChatCore
    runs-on: macos-15

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Select Xcode
        run: sudo xcode-select -s /Applications/Xcode_16.2.app/Contents/Developer

      - name: Show Swift version
        run: swift --version

      # ── Rust / MLS XCFramework ──────────────────────────────────────────────
      # CI builds the macOS arm64 slice only (native — no cross-compilation).
      # The UniFFI-generated header (sophax_mlsFFI.h) is already committed,
      # so we skip the bindgen step and just assemble the XCFramework.

      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable

      - name: Cache Rust build artefacts
        uses: actions/cache@v4
        with:
          path: rust/target
          key: rust-macos-arm64-${{ hashFiles('rust/Cargo.lock') }}
          restore-keys: rust-macos-arm64-

      - name: Build mls-rs (macOS arm64, native)
        run: |
          cd rust
          cargo build --release --lib --target aarch64-apple-darwin

      - name: Assemble XCFramework (macOS slice only)
        run: |
          HEADERS="rust/target/headers-ci"
          mkdir -p "$HEADERS" Frameworks

          # Headers are committed — copy from Generated dir
          cp Sources/SophaxChatCore/MLS/Generated/sophax_mlsFFI.h "$HEADERS/"
          cp Sources/SophaxChatCore/MLS/Generated/sophax_mlsFFI.modulemap "$HEADERS/module.modulemap"

          xcodebuild -create-xcframework \
            -library rust/target/aarch64-apple-darwin/release/libsophax_mls.a \
            -headers "$HEADERS" \
            -output Frameworks/SophaxMLS.xcframework

      # ── Swift ───────────────────────────────────────────────────────────────

      - name: Build core library
        run: swift build -c release

      - name: Run tests
        run: swift test
        continue-on-error: true   # XCTest host app tests require physical device