mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-10 02:16:45 +08:00
The remedy documented in apps/mobile/README.md for a claimed bundle identifier — export EXPO_BUNDLE_IDENTIFIER_PROD, then re-run `pnpm ios:mobile:device:prod:release` — has no effect after the first build. `expo run:ios` prebuilds only when ios/ is missing: ensureNativeProjectAsync in @expo/cli returns early when the directory exists, so config plugins never re-run and the project keeps the old identifier. The same freeze hides every other app.config.ts change. A checkout whose ios/ was generated once still had the template bundle id, an empty AppIcon.appiconset, no CFBundleDisplayName, no CFBundleURLTypes and no NSPhotoLibraryUsageDescription — while every build reported success. Route every ios:* script through scripts/ios-run.sh, which prebuilds before running. The wrapper inherits the caller's dotenv/cross-env so prebuild and run resolve the same APP_ENV and bundle identifier; a bare prebuild in a prod/staging script would rewrite the project to the dev variant. --no-install is safe because run:ios installs pods itself when Podfile.lock is stale. --clean is avoided because expo-build-properties sets buildReactNativeFromSource, making a clean prebuild far too slow for the edit/run loop. scripts/ios-run.test.sh stubs pnpm on PATH and asserts the call sequence: prebuild precedes run:ios, arguments forward to run:ios only, and a failed prebuild aborts before run:ios. It runs in mobile's existing test task. Claude-Session: https://claude.ai/code/session_01GfpPip2LPR1y9bKKEssGLG Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
84 lines
2.5 KiB
Bash
Executable File
84 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Tests for scripts/ios-run.sh.
|
|
#
|
|
# The wrapper exists so that `expo prebuild` always runs before `expo run:ios`
|
|
# (run:ios skips prebuild whenever ios/ already exists, freezing everything
|
|
# app.config.ts owns). These tests stub pnpm on PATH and assert the call
|
|
# sequence, so they need no node_modules, no Xcode, and no device.
|
|
set -eu
|
|
|
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
TEST_DIR=$(mktemp -d "${TMPDIR:-/tmp}/multica-ios-run.XXXXXX")
|
|
BIN_DIR="$TEST_DIR/bin"
|
|
CALLS_FILE="$TEST_DIR/pnpm-calls.log"
|
|
|
|
cleanup() {
|
|
rm -rf "$TEST_DIR"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
mkdir -p "$BIN_DIR"
|
|
export MULTICA_TEST_PNPM_CALLS="$CALLS_FILE"
|
|
|
|
# Stub pnpm: record every invocation, and optionally fail the prebuild so the
|
|
# abort-before-run case can be exercised.
|
|
cat >"$BIN_DIR/pnpm" <<'EOF'
|
|
#!/usr/bin/env bash
|
|
set -eu
|
|
|
|
printf '%s\n' "$*" >>"$MULTICA_TEST_PNPM_CALLS"
|
|
|
|
if [ -n "${MULTICA_TEST_FAIL_PREBUILD:-}" ]; then
|
|
case "$*" in
|
|
*prebuild*)
|
|
echo "stub prebuild failure" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
fi
|
|
EOF
|
|
chmod +x "$BIN_DIR/pnpm"
|
|
|
|
PATH="$BIN_DIR:$PATH"
|
|
export PATH
|
|
|
|
fail() {
|
|
echo "FAIL: $1" >&2
|
|
echo "--- recorded calls ---" >&2
|
|
cat "$CALLS_FILE" >&2 || true
|
|
exit 1
|
|
}
|
|
|
|
# --- prebuild runs before run:ios ------------------------------------------
|
|
: >"$CALLS_FILE"
|
|
"$SCRIPT_DIR/ios-run.sh"
|
|
|
|
expected_prebuild='exec expo prebuild -p ios --no-install'
|
|
[ "$(sed -n '1p' "$CALLS_FILE")" = "$expected_prebuild" ] ||
|
|
fail "first call should be the prebuild, got: $(sed -n '1p' "$CALLS_FILE")"
|
|
[ "$(sed -n '2p' "$CALLS_FILE")" = 'exec expo run:ios' ] ||
|
|
fail "second call should be run:ios, got: $(sed -n '2p' "$CALLS_FILE")"
|
|
[ "$(wc -l <"$CALLS_FILE")" -eq 2 ] || fail "expected exactly 2 calls"
|
|
|
|
# --- arguments forward to run:ios only --------------------------------------
|
|
: >"$CALLS_FILE"
|
|
"$SCRIPT_DIR/ios-run.sh" --device --configuration Release
|
|
|
|
[ "$(sed -n '1p' "$CALLS_FILE")" = "$expected_prebuild" ] ||
|
|
fail "prebuild must not receive run:ios arguments"
|
|
[ "$(sed -n '2p' "$CALLS_FILE")" = 'exec expo run:ios --device --configuration Release' ] ||
|
|
fail "run:ios should receive the forwarded arguments"
|
|
|
|
# --- a failed prebuild aborts before run:ios --------------------------------
|
|
: >"$CALLS_FILE"
|
|
set +e
|
|
MULTICA_TEST_FAIL_PREBUILD=1 "$SCRIPT_DIR/ios-run.sh" >/dev/null 2>&1
|
|
status=$?
|
|
set -e
|
|
|
|
[ "$status" -ne 0 ] || fail "a failed prebuild should make the wrapper exit non-zero"
|
|
grep -q 'run:ios' "$CALLS_FILE" &&
|
|
fail "run:ios must not run after a failed prebuild"
|
|
|
|
echo "ios-run.test.sh: all assertions passed"
|