GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opencode-mobile/run-ios.sh at main · opencode-mobile/opencode-mobile Expand file tree/ Copy pathrun-ios.shMore file actions executable file ·180 lines (152 loc) · 4.43 KB / Copy pathrun-ios.shFile metadata and controlsexecutable file ·180 lines (152 loc) · 4.43 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 #!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT="$ROOT_DIR/ios/OpenCode Mobile/OpenCode Mobile.xcodeproj" SCHEME="${IOS_SCHEME:-OpenCode Mobile}" BUNDLE_ID="${IOS_BUNDLE_ID:-dev.opencode.mobile}" DERIVED_DATA_PATH="${IOS_DERIVED_DATA_PATH:-$ROOT_DIR/build/ios}" CLEAN=0 VERBOSE=0 usage() { cat <<EOF Usage: ./run-ios.sh [--clean] [-v|--v|--verbose] Build and launch $SCHEME on an iPhone simulator. Options: --clean Run xcodebuild clean, remove the app from the simulator, then build -v, --v, --verbose Print full command output EOF } for arg in "$@"; do case "$arg" in --clean) CLEAN=1 ;; -v|--v|--verbose) VERBOSE=1 ;; -h|--help) usage exit 0 ;; *) echo "Unknown option: $arg" >&2 usage >&2 exit 1 ;; esac done run_quiet() { local label="$1" shift if [[ "$VERBOSE" -eq 1 ]]; then "$@" return fi local log log="$(mktemp -t "opencode-run-ios.${label}.XXXXXX")" local status=0 "$@" >"$log" 2>&1 || status=$? if [[ "$status" -eq 0 ]]; then rm -f "$log" return 0 fi echo "error: $label failed (exit $status)" >&2 tail -n 50 "$log" >&2 || true echo "Full log: $log (re-run with --v for live output)" >&2 exit "$status" } if [[ ! -d "$PROJECT" ]]; then echo "error: Missing Xcode project at $PROJECT" >&2 exit 1 fi if ! command -v xcodebuild >/dev/null 2>&1; then echo "error: xcodebuild was not found. Install Xcode command line tools." >&2 exit 1 fi if ! command -v xcrun >/dev/null 2>&1; then echo "error: xcrun was not found. Install Xcode command line tools." >&2 exit 1 fi if ! command -v python3 >/dev/null 2>&1; then echo "error: python3 was not found. It is required to choose an iOS simulator." >&2 exit 1 fi pick_simulator() { IOS_SIMULATOR_NAME="${IOS_SIMULATOR_NAME:-}" xcrun simctl list devices available -j | python3 -c ' import json import os import sys target = os.environ.get("IOS_SIMULATOR_NAME") data = json.load(sys.stdin) candidates = [] for runtime, devices in data.get("devices", {}).items(): if "iOS" not in runtime: continue for device in devices: if not device.get("isAvailable") or "iPhone" not in device.get("name", ""): continue candidates.append(device) if target: for device in candidates: if device.get("name") == target: print("{}|{}".format(device["udid"], device["name"])) sys.exit(0) print(f"No available iPhone simulator named {target!r}.", file=sys.stderr) sys.exit(2) booted = [device for device in candidates if device.get("state") == "Booted"] chosen = booted[0] if booted else candidates[0] if candidates else None if not chosen: print("No available iPhone simulators found.", file=sys.stderr) sys.exit(2) print("{}|{}".format(chosen["udid"], chosen["name"])) ' } SIMULATOR_INFO="$(pick_simulator)" SIMULATOR_UDID="${SIMULATOR_INFO%%|*}" SIMULATOR_NAME="${SIMULATOR_INFO#*|}" if [[ -z "${SIMULATOR_UDID:-}" ]]; then echo "error: Could not choose an iOS simulator." >&2 exit 1 fi if ! BOOT_OUTPUT="$(xcrun simctl boot "$SIMULATOR_UDID" 2>&1)"; then case "$BOOT_OUTPUT" in *"current state: Booted"*) ;; *) echo "error: Failed to boot simulator" >&2 if [[ "$VERBOSE" -eq 1 ]]; then echo "$BOOT_OUTPUT" >&2 fi exit 1 ;; esac fi if [[ "$VERBOSE" -eq 1 ]]; then open -a Simulator xcrun simctl bootstatus "$SIMULATOR_UDID" -b else open -a Simulator >/dev/null 2>&1 || true xcrun simctl bootstatus "$SIMULATOR_UDID" -b >/dev/null 2>&1 fi if [[ "$CLEAN" -eq 1 ]]; then run_quiet clean xcodebuild \ -project "$PROJECT" \ -scheme "$SCHEME" \ -destination "platform=iOS Simulator,id=$SIMULATOR_UDID" \ -derivedDataPath "$DERIVED_DATA_PATH" \ clean xcrun simctl uninstall "$SIMULATOR_UDID" "$BUNDLE_ID" >/dev/null 2>&1 || true fi run_quiet build xcodebuild \ -project "$PROJECT" \ -scheme "$SCHEME" \ -destination "platform=iOS Simulator,id=$SIMULATOR_UDID" \ -derivedDataPath "$DERIVED_DATA_PATH" \ build APP_PATH="$DERIVED_DATA_PATH/Build/Products/Debug-iphonesimulator/$SCHEME.app" if [[ ! -d "$APP_PATH" ]]; then echo "error: Built app not found at $APP_PATH" >&2 exit 1 fi run_quiet install xcrun simctl install "$SIMULATOR_UDID" "$APP_PATH" run_quiet launch xcrun simctl launch "$SIMULATOR_UDID" "$BUNDLE_ID" echo "success: Launched $SCHEME on $SIMULATOR_NAME." |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |