Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(mobile): re-apply app config to ios/ on every local iOS build (MUL-6206) (#6992)
Zain Mehdic99849d8a5bd
diff --git a/apps/mobile/CLAUDE.md b/apps/mobile/CLAUDE.mdindex a0b2b770e7..53563cc197 100644--- a/apps/mobile/CLAUDE.md+++ b/apps/mobile/CLAUDE.md@@ -160,6 +160,19 @@ Never copy the visual shape of an existing hand-written `components/ui/` componeMobile release cadence is decoupled from main `v*.*.*` tags (server / CLI / desktop).+### Local iOS builds go through `scripts/ios-run.sh`++Every `ios:*` script runs `expo prebuild -p ios` before `expo run:ios`. Keep it that way, and route any new iOS script through the same wrapper.++`expo run:ios` prebuilds **only when `ios/` is missing** (`ensureNativeProjectAsync` in `@expo/cli`) — when the directory exists it returns early and config plugins never re-run. Without the explicit prebuild, everything `app.config.ts` owns (app icon, bundle identifier, display name, URL scheme, Info.plist permission strings) stays pinned to whatever the first prebuild wrote, while the build still reports success. `ios/` is gitignored and fully generated, so re-prebuilding on every run is safe and idempotent.++Two things the wrapper depends on:++- `--no-install` is safe because `run:ios` installs pods itself when `Podfile.lock` is stale.+- `--clean` is avoided on purpose: `expo-build-properties` sets `buildReactNativeFromSource`, so a clean prebuild forces a from-source pod rebuild that is far too slow for the edit/run loop. Run `npx expo prebuild -p ios --clean` by hand when a native dependency changes.++The wrapper is invoked under the caller's `dotenv`/`cross-env`, so prebuild and run resolve the same `APP_ENV` and bundle identifier. A bare `expo prebuild` inside a prod/staging script would rewrite the project to the dev variant.+## Realtime / WebSocket strategyMobile uses the same WS server protocol as web/desktop, but mounts subscriptions differently. The rules below exist because mobile-specific constraints (cellular data cost, AppState lifecycle, per-screen unmount cleanup, smaller cache surface) make a direct port of web's pattern wrong.diff --git a/apps/mobile/package.json b/apps/mobile/package.jsonindex d016068b26..6069603ceb 100644--- a/apps/mobile/package.json+++ b/apps/mobile/package.json@@ -7,17 +7,17 @@"dev": "expo start","dev:staging": "dotenv -e .env.staging -- cross-env APP_ENV=staging expo start","dev:prod": "dotenv -e .env.production -- cross-env APP_ENV=production expo start",- "ios": "expo run:ios",- "ios:staging": "dotenv -e .env.staging -- cross-env APP_ENV=staging expo run:ios",- "ios:prod": "dotenv -e .env.production -- cross-env APP_ENV=production expo run:ios",- "ios:device": "expo run:ios --device",- "ios:device:staging": "dotenv -e .env.staging -- cross-env APP_ENV=staging expo run:ios --device",- "ios:device:staging:release": "dotenv -e .env.staging -- cross-env APP_ENV=staging expo run:ios --device --configuration Release",- "ios:device:prod": "dotenv -e .env.production -- cross-env APP_ENV=production expo run:ios --device",- "ios:device:prod:release": "dotenv -e .env.production -- cross-env APP_ENV=production expo run:ios --device --configuration Release",+ "ios": "./scripts/ios-run.sh",+ "ios:staging": "dotenv -e .env.staging -- cross-env APP_ENV=staging ./scripts/ios-run.sh",+ "ios:prod": "dotenv -e .env.production -- cross-env APP_ENV=production ./scripts/ios-run.sh",+ "ios:device": "./scripts/ios-run.sh --device",+ "ios:device:staging": "dotenv -e .env.staging -- cross-env APP_ENV=staging ./scripts/ios-run.sh --device",+ "ios:device:staging:release": "dotenv -e .env.staging -- cross-env APP_ENV=staging ./scripts/ios-run.sh --device --configuration Release",+ "ios:device:prod": "dotenv -e .env.production -- cross-env APP_ENV=production ./scripts/ios-run.sh --device",+ "ios:device:prod:release": "dotenv -e .env.production -- cross-env APP_ENV=production ./scripts/ios-run.sh --device --configuration Release","lint": "expo lint","typecheck": "tsc --noEmit",- "test": "vitest run"+ "test": "vitest run && bash scripts/ios-run.test.sh"},"dependencies": {"@expo/vector-icons": "^14.1.0",diff --git a/apps/mobile/scripts/ios-run.sh b/apps/mobile/scripts/ios-run.shnew file mode 100755index 0000000000..d1dca53dfb--- /dev/null+++ b/apps/mobile/scripts/ios-run.sh@@ -0,0 +1,23 @@+#!/usr/bin/env bash+# Build and run the iOS app, re-applying app.config.ts to ios/ first.+#+# `expo run:ios` only prebuilds when ios/ is missing (ensureNativeProjectAsync+# in @expo/cli): when the directory already exists it returns early and config+# plugins are never re-applied. Everything driven by app.config.ts — app icon,+# bundle identifier, display name, URL scheme, Info.plist permission strings —+# then stays frozen at whatever the first prebuild produced, while the build+# still reports success.+#+# ios/ is gitignored and fully generated, so prebuilding on every run is safe+# and idempotent. --no-install is fine because run:ios installs pods itself+# when Podfile.lock is out of date; --clean is deliberately avoided since+# expo-build-properties sets buildReactNativeFromSource, making a from-source+# pod rebuild far too slow for the normal edit/run loop.+#+# APP_ENV and the .env file are supplied by the calling package.json script, so+# prebuild and run resolve the same variant. Arguments are forwarded to+# run:ios only — prebuild takes the same flags for every variant.+set -euo pipefail++pnpm exec expo prebuild -p ios --no-install+exec pnpm exec expo run:ios "$@"diff --git a/apps/mobile/scripts/ios-run.test.sh b/apps/mobile/scripts/ios-run.test.shnew file mode 100755index 0000000000..3ce8c5b242--- /dev/null+++ b/apps/mobile/scripts/ios-run.test.sh@@ -0,0 +1,83 @@+#!/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"