@@ -70,8 +70,10 @@ build_rn_ios() {
7070 local lock=" $DEMO_DIR /ios/Podfile.lock"
7171 local stamp=" $DEMO_DIR /ios/build/.podfile.lock.stamp"
7272 if [[ ! -f " $lock " ]] || [[ ! -f " $stamp " ]] || ! cmp -s " $lock " " $stamp " ; then
73- info " Installing CocoaPods..."
74- (cd " $DEMO_DIR /ios" && pod install)
73+ # pod install never refreshes the spec repo, so a newly pinned
74+ # OneSignalXCFramework fails to resolve on a stale local cache.
75+ info " Updating OneSignalXCFramework and installing CocoaPods..."
76+ (cd " $DEMO_DIR " && vp run update:pods)
7577 mkdir -p " $( dirname " $stamp " ) "
7678 cp " $lock " " $stamp " 2> /dev/null || true
7779 else
394396expo_demo_inputs_hash () {
395397 local platform_dir=" $1 " # ios | android
396398 local content_hash
397- content_hash=$( find " $DEMO_DIR /App.tsx" " $DEMO_DIR /index.js" \
399+ content_hash=$( find " $DEMO_DIR /App.tsx" " $DEMO_DIR /index.js" " $DEMO_DIR /app " \
398400 " $DEMO_DIR /app.config.ts" " $DEMO_DIR /metro.config.js" \
399401 " $DEMO_DIR /package.json" " $DEMO_DIR /bun.lock" \
400402 " $DEMO_DIR /tsconfig.json" " $DEMO_DIR /eslint.config.js" \
@@ -429,9 +431,47 @@ expo_demo_inputs_hash() {
429431 echo " ${content_hash} -${EXPO_PLUGIN_SRC_HASH:- none} "
430432}
431433
434+ expo_demo_deps_hash () {
435+ hash_files " $DEMO_DIR /package.json" " $DEMO_DIR /bun.lock"
436+ }
437+
438+ # node_modules and the generated ios/ and android/ dirs are gitignored, so they
439+ # survive branch switches (e.g. checkout-releases.sh) and can belong to a
440+ # different Expo SDK than the checked-out source. Reinstall and re-prebuild
441+ # whenever the inputs that produced them change.
442+ prepare_expo_demo () {
443+ local platform=" $1 " # ios | android
444+ local deps_stamp=" $DEMO_DIR /node_modules/.appium-deps.stamp"
445+
446+ if [[ ! -f " $deps_stamp " ]] || [[ " $( cat " $deps_stamp " ) " != " $( expo_demo_deps_hash) " ]]; then
447+ info " Expo demo dependencies changed, reinstalling node_modules..."
448+ rm -rf " $DEMO_DIR /node_modules"
449+ # Drop the plugin entry first: vp verifies its lockfile integrity hash
450+ # before replacing it, and a stale hash makes the re-add fail.
451+ (cd " $DEMO_DIR " && vp remove onesignal-expo-plugin)
452+ fi
453+
454+ setup_expo_plugin
455+ expo_demo_deps_hash > " $deps_stamp "
456+
457+ local prebuild_stamp=" $DEMO_DIR /$platform /.appium-prebuild.stamp"
458+ local prebuild_hash
459+ prebuild_hash=" $( hash_files " $DEMO_DIR /package.json" " $DEMO_DIR /bun.lock" \
460+ " $DEMO_DIR /app.config.ts" " $DEMO_DIR /assets" \
461+ " $DEMO_DIR /customNSE" " $DEMO_DIR /customWidget" ) -${EXPO_PLUGIN_SRC_HASH:- none} "
462+ if [[ -f " $prebuild_stamp " ]] && [[ " $( cat " $prebuild_stamp " ) " == " $prebuild_hash " ]]; then
463+ info " Expo $platform native project up to date, skipping prebuild"
464+ return
465+ fi
466+
467+ info " Expo demo config or plugin changed, running expo prebuild --clean --platform $platform ..."
468+ (cd " $DEMO_DIR " && CI=1 vp exec expo prebuild --clean --platform " $platform " --no-install)
469+ echo " $prebuild_hash " > " $prebuild_stamp "
470+ }
471+
432472build_expo_ios () {
433473 write_expo_demo_env
434- setup_expo_plugin
474+ prepare_expo_demo ios
435475
436476 # Top-level skip: if neither the demo's JS/native sources nor the plugin
437477 # changed and the .app is still on disk, an xcodebuild "up to date" pass
@@ -484,7 +524,7 @@ build_expo_ios() {
484524
485525build_expo_android () {
486526 write_expo_demo_env
487- setup_expo_plugin
527+ prepare_expo_demo android
488528
489529 info " Building release APK (self-contained, no Metro required)..."
490530 (cd " $DEMO_DIR /android" && ./gradlew assembleRelease)
0 commit comments