#!/usr/bin/env bash # The apple-app example on macOS: `wai create` makes the project, the SDK's macOS slice is built # if it is not, the app builds (the SwiftUI player and the replay), and the replay must put the # recorded session through the sink and verify its bundle. # # bash wai/examples/apple-app/test/apple-app.test.sh # Needs wai on PATH, Xcode, and Rust (for the SDK's library). set -uo pipefail REPO=$(cd "$(dirname "$0")/../../../.." && pwd) SDK="$REPO/wai/wai-sink-swift" T=$(mktemp -d) wai create "$T/app" --template apple-app > /dev/null || { echo "FAIL wai create"; exit 1; } if [ ! -d "$SDK/build/WaiFFI.xcframework" ]; then (cd "$SDK" && WAI_SINK_SLICES=macos bash scripts/build-xcframework.sh > "$T/sdk.log" 2>&1) || { tail -30 "$T/sdk.log"; echo "FAIL the SDK builds"; exit 1; } fi cd "$T/app" export WAI_SINK_SWIFT="$SDK" swift build > build.log 2>&1 || { tail -40 build.log; echo "FAIL the app builds"; exit 1; } echo "ok the app builds against the SDK: the SwiftUI player and the replay" s=0 out=$(swift run --skip-build WaiApp --replay sample-session.json 2>&1) || s=$? echo " $out" | tail -2 if [ $s = 0 ]; then echo "ok the recorded session goes through the sink, and its bundle verifies"; else echo "FAIL the replay (exit $s)"; fi exit $s