@@ -19,24 +19,58 @@ if [[ -n "$PLATFORM" && "$PLATFORM" != "android" && "$PLATFORM" != "ios" ]]; the
1919 exit 1
2020fi
2121
22+ # Determine platforms, defaulting to both if missing/unreadable
23+ PLATFORMS=(" ios" " android" )
24+ PLATFORMS_RAW=$( node -e '
25+ try {
26+ const fs = require("fs");
27+ const cfg = JSON.parse(fs.readFileSync("app.json", "utf8"));
28+ const p = (cfg && cfg.expo && cfg.expo.platforms) || cfg.platforms;
29+ if (Array.isArray(p)) {
30+ console.log(p.filter(Boolean).join(","));
31+ }
32+ } catch (e) {
33+ // fall back to default
34+ }
35+ ' 2> /dev/null || true)
36+
37+ if [[ -n " $PLATFORMS_RAW " ]]; then
38+ IFS=' ,' read -r -a PLATFORMS <<< " $PLATFORMS_RAW"
39+ fi
40+
41+ # If a single platform was requested, ensure it's enabled and then narrow to it
42+ if [[ -n " $PLATFORM " ]]; then
43+ if [[ ! " ${PLATFORMS[*]} " =~ ${PLATFORM} ]]; then
44+ echo " Error: Platform '$PLATFORM ' is not enabled in app.json. Enabled platforms: ${PLATFORMS[*]} "
45+ exit 1
46+ fi
47+ PLATFORMS=(" $PLATFORM " )
48+ fi
49+
2250# Clean native projects
2351rm -rf android ios
2452
2553# Compile Expo modules
2654./scripts/compile-plugins.sh
2755
2856# Prebuild native projects
29- if [[ -z " $PLATFORM " || " $PLATFORM " == " android" ]]; then
57+ # If android is among enabled platforms
58+ if [[ " ${PLATFORMS[*]} " =~ android ]]; then
3059 npx expo prebuild --platform android
3160fi
3261
33- if [[ -z " $PLATFORM " || " $PLATFORM " == " ios" ]]; then
62+ # If iOS is among enabled platforms
63+ if [[ " ${PLATFORMS[*]} " =~ ios ]]; then
3464 npx expo prebuild --platform ios --no-install
3565
3666 # Needed for Ruby v3
3767 export RUBY_TCP_NO_FAST_FALLBACK=1
3868
69+ # Install Ruby Gems such as Cocoapods (if not already installed)
70+ if [[ ! -d vendor ]]; then
71+ bundle install
72+ fi
73+
3974 # Install the iOS dependencies using Cocoapods
40- bundle install
4175 bundle exec pod install --repo-update --project-directory=ios
4276fi
0 commit comments