1#!/usr/bin/env bash
2# setup_frameworks.sh
3# Downloads pre-built binary dependencies that are too large for git.
4# Run once before opening SophaxChat.xcodeproj.
5#
6# Dependencies:
7# tor.xcframework — iCepa/Tor.framework v409.5.1
8# Binary: libevent + OpenSSL + Tor (arm64 device + arm64/x86_64 simulator + macOS)
9# SHA-256 verified after download.
10
11set -euo pipefail
12
13REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
14FRAMEWORKS_DIR="$REPO_ROOT/Frameworks"
15
16TOR_VERSION="409.5.1"
17TOR_ZIP_URL="https://github.com/iCepa/Tor.framework/releases/download/v${TOR_VERSION}/tor.xcframework.zip"
18TOR_ZIP_SHA256="UNVERIFIED" # TODO: replace with actual SHA256 from iCepa release page
19TOR_DEST="$FRAMEWORKS_DIR/tor.xcframework"
20
21echo "==> Setting up Frameworks/"
22mkdir -p "$FRAMEWORKS_DIR"
23
24# ── Tor.framework ──────────────────────────────────────────────────────────────
25if [ -d "$TOR_DEST" ]; then
26 echo " tor.xcframework already present — skipping download."
27else
28 echo " Downloading tor.xcframework v${TOR_VERSION}..."
29 TMP=$(mktemp -d)
30 trap "rm -rf $TMP" EXIT
31
32 curl -fSL --progress-bar "$TOR_ZIP_URL" -o "$TMP/tor.zip"
33
34 # Verify integrity before unpacking
35 if [ "$TOR_ZIP_SHA256" != "UNVERIFIED" ]; then
36 ACTUAL=$(shasum -a 256 "$TMP/tor.zip" | awk '{print $1}')
37 if [ "$ACTUAL" != "$TOR_ZIP_SHA256" ]; then
38 echo "ERROR: SHA-256 mismatch for tor.zip"
39 echo " expected: $TOR_ZIP_SHA256"
40 echo " got: $ACTUAL"
41 exit 1
42 fi
43 echo " SHA-256 verified ✓"
44 else
45 echo " WARNING: SHA-256 not configured — skipping integrity check."
46 echo " Verify the download manually before building."
47 fi
48
49 unzip -q "$TMP/tor.zip" -d "$FRAMEWORKS_DIR"
50 echo " tor.xcframework installed ✓"
51fi
52
53echo ""
54echo "Done. Run 'xcodegen generate' if needed, then open SophaxChat.xcodeproj."