Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions scripts/prebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,58 @@ 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

# Compile Expo modules
./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
Loading