























@@ -15,23 +15,126 @@ XCODEGEN_BIN="${IOS_RUN_XCODEGEN_BIN:-xcodegen}"
1515SIMCTL_BIN="${IOS_RUN_SIMCTL_BIN:-xcrun simctl}"
1616PLIST_BUDDY_BIN="${IOS_RUN_PLIST_BUDDY_BIN:-/usr/libexec/PlistBuddy}"
171718+usage() {
19+ cat <<'EOF'
20+Usage: scripts/ios-run.sh [options]
21+22+Options:
23+ --push-sandbox-simulator
24+ Build with the hosted sandbox push relay and launch the simulator with an
25+ internal simulator proof secret.
26+ --push-relay-base-url <url>
27+ Override the sandbox relay URL used with --push-sandbox-simulator.
28+ Defaults to https://ios-push-relay-sandbox.openclaw.ai.
29+ --simulator-proof-secret-env <name>
30+ Environment variable that contains the simulator proof secret.
31+ Defaults to OPENCLAW_SIMULATOR_PUSH_PROOF_SECRET.
32+ -h, --help
33+ Show this help.
34+EOF
35+}
36+1837run_simctl() {
1938# shellcheck disable=SC2086
2039${SIMCTL_BIN} "$@"
2140}
224142+push_sandbox_simulator=0
43+push_relay_base_url="${OPENCLAW_PUSH_SANDBOX_RELAY_BASE_URL:-https://ios-push-relay-sandbox.openclaw.ai}"
44+simulator_proof_secret_env="${OPENCLAW_SIMULATOR_PUSH_PROOF_SECRET_ENV:-OPENCLAW_SIMULATOR_PUSH_PROOF_SECRET}"
45+46+while [[ $# -gt 0 ]]; do
47+case "$1" in
48+ --push-sandbox-simulator)
49+ push_sandbox_simulator=1
50+ ;;
51+ --push-relay-base-url)
52+if [[ $# -lt 2 || -z "$2" ]]; then
53+echo "ERROR: --push-relay-base-url requires a URL" >&2
54+exit 1
55+fi
56+ push_relay_base_url="$2"
57+shift
58+ ;;
59+ --simulator-proof-secret-env)
60+if [[ $# -lt 2 || -z "$2" ]]; then
61+echo "ERROR: --simulator-proof-secret-env requires an environment variable name" >&2
62+exit 1
63+fi
64+ simulator_proof_secret_env="$2"
65+shift
66+ ;;
67+ -h | --help)
68+ usage
69+exit 0
70+ ;;
71+*)
72+echo "ERROR: Unknown argument: $1" >&2
73+ usage >&2
74+exit 1
75+ ;;
76+esac
77+shift
78+done
79+80+xcodebuild_overrides=()
81+simulator_proof_secret=""
82+83+if [[ ! "${simulator_proof_secret_env}" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then
84+echo "ERROR: Invalid simulator proof secret environment variable name" >&2
85+exit 1
86+fi
87+88+if [[ "${push_sandbox_simulator}" == "1" ]]; then
89+ simulator_proof_secret="${!simulator_proof_secret_env:-}"
90+if [[ -z "${simulator_proof_secret}" ]]; then
91+echo "ERROR: ${simulator_proof_secret_env} must be set for --push-sandbox-simulator" >&2
92+exit 1
93+fi
94+if [[ "${#simulator_proof_secret}" -lt 32 ]]; then
95+echo "ERROR: ${simulator_proof_secret_env} must contain at least 32 characters" >&2
96+exit 1
97+fi
98+99+ xcodebuild_overrides+=(
100+"OPENCLAW_PUSH_TRANSPORT=relay"
101+"OPENCLAW_PUSH_DISTRIBUTION=official"
102+"OPENCLAW_PUSH_RELAY_BASE_URL=${push_relay_base_url}"
103+"OPENCLAW_PUSH_APNS_ENVIRONMENT=sandbox"
104+"OPENCLAW_PUSH_RELAY_PROFILE=simulatorSandbox"
105+"OPENCLAW_PUSH_PROOF_POLICY=internalSimulator"
106+"OPENCLAW_APNS_ENTITLEMENT_ENVIRONMENT=development"
107+ )
108+fi
109+110+unset "${simulator_proof_secret_env}"
111+if [[ "${simulator_proof_secret_env}" != "OPENCLAW_SIMULATOR_PUSH_PROOF_SECRET" ]]; then
112+unset OPENCLAW_SIMULATOR_PUSH_PROOF_SECRET
113+fi
114+23115"${ROOT_DIR}/scripts/ios-configure-signing.sh"
24116"${ROOT_DIR}/scripts/ios-write-version-xcconfig.sh"
2511726118cd "${IOS_DIR}"
27119"${XCODEGEN_BIN}" generate
28-"${XCODEBUILD_BIN}" \
29- -project OpenClaw.xcodeproj \
30- -scheme OpenClaw \
31- -destination "${IOS_DESTINATION}" \
32- -configuration "${CONFIGURATION}" \
33- -derivedDataPath "${DERIVED_DATA_DIR}" \
34- build
120+if [[ "${push_sandbox_simulator}" == "1" ]]; then
121+"${XCODEBUILD_BIN}" \
122+ -project OpenClaw.xcodeproj \
123+ -scheme OpenClaw \
124+ -destination "${IOS_DESTINATION}" \
125+ -configuration "${CONFIGURATION}" \
126+ -derivedDataPath "${DERIVED_DATA_DIR}" \
127+ build \
128+"${xcodebuild_overrides[@]}"
129+else
130+"${XCODEBUILD_BIN}" \
131+ -project OpenClaw.xcodeproj \
132+ -scheme OpenClaw \
133+ -destination "${IOS_DESTINATION}" \
134+ -configuration "${CONFIGURATION}" \
135+ -derivedDataPath "${DERIVED_DATA_DIR}" \
136+ build
137+fi
3513836139app_path="${DERIVED_DATA_DIR}/Build/Products/${CONFIGURATION}-iphonesimulator/${APP_NAME}.app"
37140if [[ ! -d "${app_path}" ]]; then
@@ -54,4 +157,10 @@ if ! boot_output="$(run_simctl boot "${SIMULATOR_TARGET}" 2>&1)"; then
54157fi
5515856159run_simctl install "${SIMULATOR_TARGET}" "${app_path}"
57-run_simctl launch "${SIMULATOR_TARGET}" "${bundle_id}"
160+if [[ "${push_sandbox_simulator}" == "1" ]]; then
161+# shellcheck disable=SC2086
162+ SIMCTL_CHILD_OPENCLAW_SIMULATOR_PUSH_PROOF_SECRET="${simulator_proof_secret}" \
163+${SIMCTL_BIN} launch "${SIMULATOR_TARGET}" "${bundle_id}"
164+else
165+ run_simctl launch "${SIMULATOR_TARGET}" "${bundle_id}"
166+fi
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。