From 398774edfff02a7aa8c444d3ed6a839f71f9a775 Mon Sep 17 00:00:00 2001 From: jpdriver Date: Wed, 13 Aug 2025 10:54:44 -0700 Subject: [PATCH] prebuild performance improvements --- scripts/prebuild.sh | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/scripts/prebuild.sh b/scripts/prebuild.sh index 15140f8..d2cf7c7 100755 --- a/scripts/prebuild.sh +++ b/scripts/prebuild.sh @@ -19,6 +19,34 @@ if [[ -n "$PLATFORM" && "$PLATFORM" != "android" && "$PLATFORM" != "ios" ]]; the exit 1 fi +# Determine platforms, defaulting to both if missing/unreadable +PLATFORMS=("ios" "android") +PLATFORMS_RAW=$(node -e ' + try { + const fs = require("fs"); + const cfg = JSON.parse(fs.readFileSync("app.json", "utf8")); + const p = (cfg && cfg.expo && cfg.expo.platforms) || cfg.platforms; + if (Array.isArray(p)) { + console.log(p.filter(Boolean).join(",")); + } + } catch (e) { + // fall back to default + } +' 2>/dev/null || true) + +if [[ -n "$PLATFORMS_RAW" ]]; then + IFS=',' read -r -a PLATFORMS <<< "$PLATFORMS_RAW" +fi + +# If a single platform was requested, ensure it's enabled and then narrow to it +if [[ -n "$PLATFORM" ]]; then + if [[ ! " ${PLATFORMS[*]} " =~ ${PLATFORM} ]]; then + echo "Error: Platform '$PLATFORM' is not enabled in app.json. Enabled platforms: ${PLATFORMS[*]}" + exit 1 + fi + PLATFORMS=("$PLATFORM") +fi + # Clean native projects rm -rf android ios @@ -26,17 +54,23 @@ rm -rf android ios ./scripts/compile-plugins.sh # Prebuild native projects -if [[ -z "$PLATFORM" || "$PLATFORM" == "android" ]]; then +# If android is among enabled platforms +if [[ " ${PLATFORMS[*]} " =~ android ]]; then npx expo prebuild --platform android fi -if [[ -z "$PLATFORM" || "$PLATFORM" == "ios" ]]; then +# If iOS is among enabled platforms +if [[ " ${PLATFORMS[*]} " =~ ios ]]; then npx expo prebuild --platform ios --no-install # Needed for Ruby v3 export RUBY_TCP_NO_FAST_FALLBACK=1 + # Install Ruby Gems such as Cocoapods (if not already installed) + if [[ ! -d vendor ]]; then + bundle install + fi + # Install the iOS dependencies using Cocoapods - bundle install bundle exec pod install --repo-update --project-directory=ios fi \ No newline at end of file