Files
multica/apps/mobile/scripts/ios-run.sh
Zain MehdiandClaude Opus 5 c99849d8a5 fix(mobile): re-apply app config to ios/ on every local iOS build (MUL-6206) (#6992)
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]>
2026-08-16 23:58:39 +08:00

24 lines
1.2 KiB
Bash
Executable File

#!/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 "$@"