#!/bin/sh # Builds the app, runs it in the simulator and, with a route, opens that screen: # ios/run.sh [route] see DevRoute in Knotless/App.swift # With goat logged in and KNOTLESS_ACTOR set, a debug build asks as that account # for the methods below, with service tokens of an hour each, kept outside the app. set -eu cd "$(dirname "$0")" device=${KNOTLESS_DEVICE:-iPhone 17 Pro} tokens=$PWD/build/.tokens.json xcodegen generate --quiet xcodebuild -quiet -project Knotless.xcodeproj -scheme Knotless -jobs 2 -allowProvisioningUpdates \ -destination "platform=iOS Simulator,name=$device" -derivedDataPath build build xcrun simctl boot "$device" 2>/dev/null || true xcrun simctl install "$device" build/Build/Products/Debug-iphonesimulator/Knotless.app if [ -n "${KNOTLESS_ACTOR:-}" ] && [ ! -f "$tokens" -o -n "$(find "$tokens" -mmin +50 2>/dev/null)" ]; then umask 077 { printf '{'; sep='' for lxm in getViewer getActorRepos getActorStars getProfile listNotifications getThread getMergeStatus getPullDiff getRepo getTree getFile listItems; do t=$(goat account service-auth --aud did:web:knotless.dev --lxm "dev.knotless.$lxm" --duration-sec 3600) printf '%s"dev.knotless.%s":"%s"' "$sep" "$lxm" "$t"; sep=, done printf '}' } > "$tokens" fi xcrun simctl terminate "$device" dev.knotless.app 2>/dev/null || true SIMCTL_CHILD_KNOTLESS_TOKENS=$tokens \ SIMCTL_CHILD_KNOTLESS_ROUTE=${1:-} xcrun simctl launch "$device" dev.knotless.app