11#! /bin/bash
2-
2+ set -x
33# Android functions
44
55ARCH=" x86_64"
@@ -103,67 +103,46 @@ function start_with_snapshots() {
103103SIMULATOR_DEVICE=" iPhone 15 Pro Max"
104104SIMULATOR_OS=" 18.2"
105105
106- # Define an array of uppercase words for simulator names
107- NUMBER_WORDS=(" FIRST" " SECOND" " THIRD" " FOURTH" " FIFTH" " SIXTH" " SEVENTH" " EIGHTH" " NINTH" " TENTH" " ELEVENTH" " TWELFTH" )
108-
109106# Function to boot simulators from environment variables
110107function start_simulators_from_env_iOS() {
111108 echo " Starting iOS simulators from environment variables"
112109
113- set -x
114110
115111 for i in {1..12}; do
116- simulator_label=${NUMBER_WORDS[$((i - 1))]}
112+ simulator_label=$i
117113 env_var=" IOS_${simulator_label} _SIMULATOR"
118114 simulator_udid=$( printenv " $env_var " )
119115
120116 echo " Iteration $i : Label: $simulator_label , Env var: $env_var , UDID: $simulator_udid "
121117
122118 if [[ -n " $simulator_udid " ]]; then
123- # Check if the simulator is already booted
124- booted=$( xcrun simctl list devices booted | grep " $simulator_udid " )
125- echo " Current booted status for $simulator_udid : $booted "
126-
127- if [[ -n " $booted " ]]; then
128- echo " $simulator_label simulator ($simulator_udid ) is already booted. Attempting shutdown..."
129- shutdown_output=$( xcrun simctl shutdown " $simulator_udid " 2>&1 )
130- shutdown_status=$?
131- echo " Shutdown command output: $shutdown_output "
132- echo " Shutdown command exit code: $shutdown_status "
133- if [[ $shutdown_status -ne 0 ]]; then
134- echo " Error: Shutdown command failed for $simulator_udid "
135- exit 100
136- fi
137- sleep 5
138- fi
139-
119+
140120 echo " Booting $simulator_label simulator: $simulator_udid "
141121 boot_output=$( xcrun simctl boot " $simulator_udid " 2>&1 )
142122 boot_status=$?
143123 echo " Boot command output: $boot_output "
144124 echo " Boot command exit code: $boot_status "
145125 if [[ $boot_status -ne 0 ]]; then
146126 echo " Error: Boot command failed for $simulator_udid "
147- exit 101
127+ return 101
148128 fi
149129 sleep 5
150130
151131 booted=$( xcrun simctl list devices booted | grep " $simulator_udid " )
152132 echo " Post-boot status for $simulator_udid : $booted "
153133 if [[ -z " $booted " ]]; then
154134 echo " Error: Simulator $simulator_udid did not boot successfully."
155- exit 102
135+ return 102
156136 fi
157137 else
158138 echo " Error: $simulator_label simulator (env var $env_var ) is not set"
159- exit 104
139+ return 104
160140 fi
161141 done
162142
163143 echo " Opening iOS Simulator app..."
164144 open -a Simulator
165145
166- set +x
167146}
168147
169148
@@ -173,7 +152,7 @@ function start_simulators_from_env_iOS() {
173152# Function to start the Appium server
174153function start_appium_server() {
175154 echo " Starting Appium server..."
176- cd forked-session-appium || exit 110
155+ cd forked-session-appium || return 110
177156 start-server
178157}
179158
@@ -182,7 +161,7 @@ function stop_simulators_from_env_iOS() {
182161 echo " Stopping iOS simulators from environment variables..."
183162
184163 for i in {1..12}; do
185- simulator_label=${NUMBER_WORDS[$((i - 1))]}
164+ simulator_label=$i
186165 env_var=" IOS_${simulator_label} _SIMULATOR"
187166 simulator_udid=$( printenv " $env_var " )
188167
@@ -192,11 +171,11 @@ function stop_simulators_from_env_iOS() {
192171 echo " Stopping $simulator_label simulator: $simulator_udid "
193172 xcrun simctl shutdown " $simulator_udid "
194173 else
195- echo " $simulator_label simulator is not running or does not exist."
196- exit 120
174+ echo " $simulator_label simulator is not running or does not exist... skipping"
197175 fi
198176 else
199177 echo " Skipping $simulator_label simulator (not set)"
178+ return 120
200179 fi
201180 done
202181}
0 commit comments