#!/usr/bin/env bash # Build the OffTail Tailscale core into an iOS .xcframework via gomobile, from the Go shim in ../gocore. # Output: modules/officer-net/ios/libs/TailCore.xcframework (gitignored; the podspec vendors it when present). # # Unlike bw-vault (which fetches a prebuilt Bitwarden release asset), Tailscale publishes no third-party # gomobile framework — WE produce it once with `gomobile bind`, then vendor it. PROVEN working on # Go 1.26 + Xcode 26: binds tailscale.com (tsnet/ipn/wgengine/magicsock/netstack) to arm64 + sim. # # Requires: Go + gomobile + gobind on PATH: # go install golang.org/x/mobile/cmd/gomobile@latest # go install golang.org/x/mobile/cmd/gobind@latest # # Keep TAILSCALE_REF paired with the Headscale version you run — Headscale tracks a specific Tailscale # client protocol version, and a core built far ahead of it will fail to register. set -euo pipefail TAILSCALE_REF="${TAILSCALE_REF:-v1.102.0}" HERE="$(cd "$(dirname "$0")/.." && pwd)" # modules/officer-net GOCORE="$HERE/gocore" OUT="$HERE/ios/libs/TailCore.xcframework" export PATH="$(go env GOPATH)/bin:$PATH" command -v gomobile >/dev/null 2>&1 || { echo "✗ gomobile not on PATH — go install golang.org/x/mobile/cmd/gomobile@latest"; exit 1; } cd "$GOCORE" [ -f go.mod ] || go mod init officer.dev/tailcore echo "→ pinning tailscale.com@${TAILSCALE_REF}" go get "tailscale.com@${TAILSCALE_REF}" # gomobile (Go 1.26) needs x/mobile as a tool dep AND bind imported, or `go mod tidy` prunes it and the # bind fails with "missing golang.org/x/mobile dependency". go get -tool golang.org/x/mobile/cmd/gobind go get golang.org/x/mobile/bind echo "→ gomobile bind -target=ios (compiles the whole Tailscale core; a few minutes)" mkdir -p "$HERE/ios/libs" rm -rf "$OUT" gomobile bind -target=ios -o "$OUT" ./ [ -d "$OUT" ] || { echo "✗ bind produced no framework" >&2; exit 1; } echo "✔ built $OUT"; du -sh "$OUT"