#!/bin/bash # Xcode "Run Script" build phase: builds audiotee, transcriptor-ai, and # qwen_asr and embeds them in this app's bundle — the "one-click install" # requirement (see CLAUDE.md, "Goal"). Only the AI model is left to fetch # at runtime; everything else is baked in here. # # audiotee is a git submodule (third_party/audiotee, pinned to a commit on # our own Gitea fork — see CLAUDE.md) — same pattern transcriptor-ai # already uses for qwen-asr, and for the same reason: this script shouldn't # depend on a sibling checkout existing at some assumed path on whatever # machine builds this. transcriptor-ai itself is still a sibling-directory # dependency (`../transcriptor-ai`) — not converted to a submodule, that # wasn't asked for and isn't needed to fix the audiotee fragility this was # about. # # Expects Xcode's build environment variables (SRCROOT, BUILT_PRODUCTS_DIR, # UNLOCALIZED_RESOURCES_FOLDER_PATH). Run manually for debugging via: # SRCROOT=$(pwd) BUILT_PRODUCTS_DIR=/tmp/embed-test \ # UNLOCALIZED_RESOURCES_FOLDER_PATH=transcriptor.app/Contents/Resources \ # scripts/embed-binaries.sh set -euo pipefail # Xcode Run Script phases don't inherit a normal interactive-shell PATH — # Homebrew's go/etc. aren't found without this (bit us during manual # testing throughout this session too). export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" SRCROOT="${SRCROOT:?SRCROOT must be set (run via Xcode, or set it manually — see header comment)}" REPO_ROOT="$(cd "$SRCROOT" && pwd)" AUDIOTEE_REPO="$REPO_ROOT/third_party/audiotee" TRANSCRIPTOR_AI_REPO="$(cd "$REPO_ROOT/../transcriptor-ai" && pwd)" echo "Ensuring audiotee submodule is present (pinned commit)..." git -C "$REPO_ROOT" submodule update --init --recursive third_party/audiotee echo "Building audiotee..." "$AUDIOTEE_REPO/scripts/build-signed.sh" echo "Building transcriptor-ai + qwen_asr..." "$TRANSCRIPTOR_AI_REPO/scripts/build-dist.sh" RESOURCES_DIR="${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" mkdir -p "$RESOURCES_DIR" cp "$HOME/bin/audiotee" "$RESOURCES_DIR/audiotee" cp "$TRANSCRIPTOR_AI_REPO/dist/transcriptor-ai" "$RESOURCES_DIR/transcriptor-ai" cp "$TRANSCRIPTOR_AI_REPO/dist/qwen_asr" "$RESOURCES_DIR/qwen_asr" chmod +x "$RESOURCES_DIR/audiotee" "$RESOURCES_DIR/transcriptor-ai" "$RESOURCES_DIR/qwen_asr" echo "Embedded binaries in $RESOURCES_DIR:" ls -la "$RESOURCES_DIR/audiotee" "$RESOURCES_DIR/transcriptor-ai" "$RESOURCES_DIR/qwen_asr"