#!/bin/zsh set -e d=${0:a:h} source $d/config.zsh cd $d echo "Running iOS preview workflow..." cd "$REPO_DIR" # 0. Environment Setup (Fix Node Version) export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm echo "Checking Node version..." # Try to use LTS or v22/v20 if available, as v25 causes build errors with better-sqlite3 if command -v nvm >/dev/null; then nvm use 22 || nvm use 20 || echo "Warning: Could not switch to Node 22/20. Current: $(node -v)" else echo "nvm not found, using system node: $(node -v)" fi # 1. Install dependencies echo "1. Installing dependencies (yarn)..." yarn install # 2. Prebuild (Generate ios directory) echo "2. Running Expo Prebuild..." # Clean old ios folder if exists to ensure fresh config application rm -rf ios npx expo prebuild --platform ios --clean # 3. CocoaPods echo "3. Installing CocoaPods..." # Ensure PATH includes Homebrew ruby gems if needed (User suggestion) export PATH="/opt/homebrew/lib/ruby/gems/3.4.0/bin:$PATH" cd ios pod install cd .. # 4. Signing (Manual Step) echo "4. Opening Xcode for Signing..." # Find the project file #XCODE_PROJ=$(find ios -name "*.xcodeproj" | head -n 1) open ./ios/${APP_NAME}.xcodeproj # 5. Run echo "5. Building and Running on device $DEVICE_ID..." npx expo run:ios #npx expo run:ios --device "$DEVICE_ID" --configuration Release