diff --git a/appium/scripts/run-local/build.sh b/appium/scripts/run-local/build.sh index caa8ddd..5dd2c6b 100644 --- a/appium/scripts/run-local/build.sh +++ b/appium/scripts/run-local/build.sh @@ -1,6 +1,37 @@ #!/usr/bin/env bash # ── 1. Build app ───────────────────────────────────────────────────────────── +ensure_flutter_swift_package_manager() { + # Without SPM, flutter build ios falls back to CocoaPods for onesignal_flutter + # and fails on the prebuilt OneSignal XCFramework (Multiple commands produce + # XCFrameworkIntermediates, or Podfile.lock vs podspec version skew). + if flutter config --list 2>/dev/null | grep -q 'enable-swift-package-manager: true'; then + return 0 + fi + info "Enabling Flutter Swift Package Manager (required for OneSignal iOS builds)..." + flutter config --enable-swift-package-manager +} + +sync_flutter_onesignal_xcframework_pod() { + # NSE/Widget extension targets still resolve OneSignalXCFramework via CocoaPods + # even when SPM owns the Flutter plugin. Podfile.lock often lags the podspec + # pin after an iOS SDK bump (e.g. 5.4.1 lock vs 5.5.0 podspec). + local lock="$DEMO_DIR/ios/Podfile.lock" + local podspec="$FLUTTER_DIR/ios/onesignal_flutter.podspec" + [[ -f "$lock" && -f "$podspec" ]] || return 0 + + local locked wanted + locked="$(awk '/^- OneSignalXCFramework \(/ { + if (match($0, /[0-9]+\.[0-9]+\.[0-9]+/)) { print substr($0, RSTART, RLENGTH); exit } + }' "$lock" 2>/dev/null || true)" + wanted="$(awk -F"'" '/OneSignalXCFramework/ { print $4; exit }' "$podspec" 2>/dev/null || true)" + + [[ -n "$locked" && -n "$wanted" && "$locked" != "$wanted" ]] || return 0 + + info "Updating OneSignalXCFramework CocoaPods pin ($locked -> $wanted)..." + (cd "$DEMO_DIR/ios" && pod update OneSignalXCFramework --repo-update) +} + build_flutter_ios() { if [[ -n "${ONESIGNAL_APP_ID:-}" && -n "${ONESIGNAL_API_KEY:-}" ]]; then info "Writing .env for demo app..." @@ -12,11 +43,12 @@ EOF warn "ONESIGNAL_APP_ID / ONESIGNAL_API_KEY not set — skipping demo .env" fi + ensure_flutter_swift_package_manager + info "Installing Flutter dependencies..." (cd "$FLUTTER_DIR" && flutter pub get) - # info "Installing CocoaPods..." - # (cd "$DEMO_DIR/ios" && pod install) + sync_flutter_onesignal_xcframework_pod info "Building debug .app for simulator (this may take a few minutes)..." (cd "$DEMO_DIR" && flutter build ios --simulator --debug) diff --git a/appium/scripts/run-local/config.sh b/appium/scripts/run-local/config.sh index 3ce7eca..25e3df2 100644 --- a/appium/scripts/run-local/config.sh +++ b/appium/scripts/run-local/config.sh @@ -185,6 +185,16 @@ USAGE || error "Appium driver '$driver' is not installed. Install it with: appium driver install $driver (check what's installed with: appium driver list --installed)" + # Vite+ installs into ~/.vite-plus/bin and updates shell rc files, but the + # current terminal (e.g. right after bootstrap.sh) may not have sourced + # ~/.vite-plus/env yet. Prepend the shim dir when the binary is present. + if ! command -v vpx >/dev/null 2>&1; then + local vp_bin="$HOME/.vite-plus/bin" + if [[ -x "$vp_bin/vpx" ]]; then + export PATH="$vp_bin:$PATH" + info "Added $vp_bin to PATH for this run (restart the shell or: source \"$HOME/.vite-plus/env\")." + fi + fi if ! command -v vpx >/dev/null 2>&1; then if [[ -x "$HOME/.vite-plus/current/bin/vp" ]]; then error "vpx not found on PATH, but Vite+ is installed — the vpx symlink is missing or ~/.vite-plus/bin isn't on PATH. Run $SCRIPT_DIR/bootstrap.sh (or: ln -sf ../current/bin/vp ~/.vite-plus/bin/vpx && open a new shell / source ~/.vite-plus/env)."