-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·75 lines (58 loc) · 1.99 KB
/
run.sh
File metadata and controls
executable file
·75 lines (58 loc) · 1.99 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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
DERIVED_DATA_PATH="$ROOT_DIR/build"
APP_PATH="$DERIVED_DATA_PATH/Build/Products/Debug-iphoneos/Bitkit.app"
BUNDLE_ID="to.bitkit"
DEVICE_LIST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/bitkit-devices.XXXXXX")"
DEVICE_LIST_JSON="$DEVICE_LIST_DIR/devices.json"
trap 'rm -rf "$DEVICE_LIST_DIR"' EXIT
if ! command -v python3 >/dev/null 2>&1; then
echo "python3 is required to parse the devicectl device list." >&2
exit 1
fi
echo "Looking for connected iPhones..."
xcrun devicectl list devices \
--filter "hardwareProperties.deviceType == 'iPhone' AND hardwareProperties.reality == 'physical'" \
--timeout 10 \
--json-output "$DEVICE_LIST_JSON" >/dev/null
if ! DEVICE_INFO="$(
python3 - "$DEVICE_LIST_JSON" <<'PY'
import json
import sys
with open(sys.argv[1], "r", encoding="utf-8") as file:
payload = json.load(file)
devices = payload.get("result", {}).get("devices", [])
if not devices:
raise SystemExit(1)
device = devices[0]
name = device.get("deviceProperties", {}).get("name", "Unknown iPhone")
identifier = device.get("identifier")
if not identifier:
raise SystemExit(1)
print(f"{identifier}\t{name}")
PY
)"; then
echo "No connected physical iPhone found." >&2
exit 1
fi
DEVICE_ID="${DEVICE_INFO%%$'\t'*}"
DEVICE_NAME="${DEVICE_INFO#*$'\t'}"
echo "Using $DEVICE_NAME ($DEVICE_ID)"
echo "Building Debug app..."
xcodebuild \
-project "$ROOT_DIR/Bitkit.xcodeproj" \
-scheme Bitkit \
-configuration Debug \
-destination "generic/platform=iOS" \
-derivedDataPath "$DERIVED_DATA_PATH" \
build
LDK_STUB_PATH="$APP_PATH/Frameworks/LDKNodeFFI.framework"
if [[ -d "$LDK_STUB_PATH" ]]; then
echo "Removing LDKNodeFFI static framework stub..."
rm -rf "$LDK_STUB_PATH"
fi
echo "Installing $APP_PATH..."
xcrun devicectl device install app --device "$DEVICE_ID" "$APP_PATH"
echo "Launching $BUNDLE_ID..."
xcrun devicectl device process launch --device "$DEVICE_ID" "$BUNDLE_ID" --terminate-existing --console