1
1
#! /bin/bash
2
-
2
+ set -x
3
3
# Android functions
4
4
5
5
ARCH=" x86_64"
@@ -103,67 +103,46 @@ function start_with_snapshots() {
103
103
SIMULATOR_DEVICE=" iPhone 15 Pro Max"
104
104
SIMULATOR_OS=" 18.2"
105
105
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
-
109
106
# Function to boot simulators from environment variables
110
107
function start_simulators_from_env_iOS() {
111
108
echo " Starting iOS simulators from environment variables"
112
109
113
- set -x
114
110
115
111
for i in {1..12}; do
116
- simulator_label=${NUMBER_WORDS[$((i - 1))]}
112
+ simulator_label=$i
117
113
env_var=" IOS_${simulator_label} _SIMULATOR"
118
114
simulator_udid=$( printenv " $env_var " )
119
115
120
116
echo " Iteration $i : Label: $simulator_label , Env var: $env_var , UDID: $simulator_udid "
121
117
122
118
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
+
140
120
echo " Booting $simulator_label simulator: $simulator_udid "
141
121
boot_output=$( xcrun simctl boot " $simulator_udid " 2>&1 )
142
122
boot_status=$?
143
123
echo " Boot command output: $boot_output "
144
124
echo " Boot command exit code: $boot_status "
145
125
if [[ $boot_status -ne 0 ]]; then
146
126
echo " Error: Boot command failed for $simulator_udid "
147
- exit 101
127
+ return 101
148
128
fi
149
129
sleep 5
150
130
151
131
booted=$( xcrun simctl list devices booted | grep " $simulator_udid " )
152
132
echo " Post-boot status for $simulator_udid : $booted "
153
133
if [[ -z " $booted " ]]; then
154
134
echo " Error: Simulator $simulator_udid did not boot successfully."
155
- exit 102
135
+ return 102
156
136
fi
157
137
else
158
138
echo " Error: $simulator_label simulator (env var $env_var ) is not set"
159
- exit 104
139
+ return 104
160
140
fi
161
141
done
162
142
163
143
echo " Opening iOS Simulator app..."
164
144
open -a Simulator
165
145
166
- set +x
167
146
}
168
147
169
148
@@ -173,30 +152,13 @@ function start_simulators_from_env_iOS() {
173
152
# Function to start the Appium server
174
153
function start_appium_server() {
175
154
echo " Starting Appium server..."
176
- cd forked-session-appium || exit 110
155
+ cd forked-session-appium || return 110
177
156
start-server
178
157
}
179
158
180
159
# Function to stop running simulators
181
160
function stop_simulators_from_env_iOS() {
182
161
echo " Stopping iOS simulators from environment variables..."
162
+ xcrun simctl shutdown all
183
163
184
- for i in {1..12}; do
185
- simulator_label=${NUMBER_WORDS[$((i - 1))]}
186
- env_var=" IOS_${simulator_label} _SIMULATOR"
187
- simulator_udid=$( printenv " $env_var " )
188
-
189
- if [[ -n " $simulator_udid " ]]; then
190
- # Check if the simulator is running
191
- if xcrun simctl list devices booted | grep -q " $simulator_udid " ; then
192
- echo " Stopping $simulator_label simulator: $simulator_udid "
193
- xcrun simctl shutdown " $simulator_udid "
194
- else
195
- echo " $simulator_label simulator is not running or does not exist."
196
- exit 120
197
- fi
198
- else
199
- echo " Skipping $simulator_label simulator (not set)"
200
- fi
201
- done
202
164
}
0 commit comments