@@ -171,40 +171,67 @@ jobs:
171171 xcrun simctl shutdown all || true
172172 sleep 5
173173
174- # Boot iPhone 16 with specific device ID to avoid ambiguity
175- xcrun simctl boot "iPhone 16" || true
174+ # Try iPhone 15 first (often more reliable in CI)
175+ echo "Trying iPhone 15 first..."
176+ xcrun simctl boot "iPhone 15" || true
176177
177- # Wait longer for simulator to boot and add retry logic
178+ # Wait for simulator to boot
178179 echo "Waiting for simulator to boot..."
179180 for i in {1..30}; do
180- if xcrun simctl list devices | grep "iPhone 16" | grep -q "Booted"; then
181- echo "Simulator is booted!"
181+ if xcrun simctl list devices | grep "iPhone 15" | grep -q "Booted"; then
182+ echo "iPhone 15 is booted!"
183+ SIMULATOR_NAME="iPhone 15"
182184 break
183185 fi
184- echo "Waiting for simulator boot... ($i/30)"
186+ echo "Waiting for iPhone 15 boot... ($i/30)"
185187 sleep 5
186188 done
187189
190+ # If iPhone 15 failed, try iPhone 16
191+ if [ -z "$SIMULATOR_NAME" ]; then
192+ echo "iPhone 15 failed, trying iPhone 16..."
193+ xcrun simctl shutdown "iPhone 15" || true
194+ xcrun simctl boot "iPhone 16" || true
195+
196+ for i in {1..30}; do
197+ if xcrun simctl list devices | grep "iPhone 16" | grep -q "Booted"; then
198+ echo "iPhone 16 is booted!"
199+ SIMULATOR_NAME="iPhone 16"
200+ break
201+ fi
202+ echo "Waiting for iPhone 16 boot... ($i/30)"
203+ sleep 5
204+ done
205+ fi
206+
207+ if [ -z "$SIMULATOR_NAME" ]; then
208+ echo "Both simulators failed to boot"
209+ exit 1
210+ fi
211+
188212 # Additional wait for simulator to be fully ready
189213 sleep 15
190214
191215 # Install the app
192- xcrun simctl install "iPhone 16 " e2e-app/bitkit.app
216+ xcrun simctl install "$SIMULATOR_NAME " e2e-app/bitkit.app
193217
194218 # Verify app installation
195- xcrun simctl listapps "iPhone 16 " | grep -i bitkit || echo "App not found in simulator"
219+ xcrun simctl listapps "$SIMULATOR_NAME " | grep -i bitkit || echo "App not found in simulator"
196220
197221 # Check simulator status
198- xcrun simctl list devices | grep "iPhone 16 "
222+ xcrun simctl list devices | grep "$SIMULATOR_NAME "
199223
200224 # Launch simulator app to ensure it's visible
201225 open -a Simulator
202226 sleep 5
227+
228+ # Export simulator name for later use
229+ echo "SIMULATOR_NAME=$SIMULATOR_NAME" >> $GITHUB_ENV
203230
204231 - name : Start Appium Server
205232 run : |
206233 # Start Appium server in background with more verbose logging
207- appium --port 4723 --log-level debug --relaxed-security &
234+ appium --port 4723 --log-level debug --relaxed-security --session-override &
208235 APPIUM_PID=$!
209236 echo "APPIUM_PID=$APPIUM_PID" >> $GITHUB_ENV
210237
@@ -228,6 +255,14 @@ jobs:
228255 # Test Appium with a simple request
229256 echo "Testing Appium connection..."
230257 curl -s http://localhost:4723/status | head -20
258+
259+ # Check if simulator is accessible to Appium
260+ echo "Checking simulator accessibility..."
261+ xcrun simctl list devices | grep "iPhone 16"
262+
263+ # Try to get simulator logs to debug
264+ echo "Recent simulator logs:"
265+ xcrun simctl spawn "iPhone 16" log show --last 1m --predicate 'process == "SpringBoard"' | head -10
231266
232267 - name : Run E2E Tests (${{ matrix.shard.name }})
233268 run : |
@@ -239,7 +274,7 @@ jobs:
239274 LOGFILE="$LOGDIR/simulator.log"
240275
241276 # Start simulator logging
242- xcrun simctl spawn "iPhone 16 " log stream --predicate 'process == "Bitkit"' --style compact > "$LOGFILE" &
277+ xcrun simctl spawn "$SIMULATOR_NAME " log stream --predicate 'process == "Bitkit"' --style compact > "$LOGFILE" &
243278 LOG_PID=$!
244279
245280 # Cleanup function
@@ -259,6 +294,15 @@ jobs:
259294 sed -i '' 's/connectionRetryTimeout: [0-9]*/connectionRetryTimeout: 300000/' wdio.conf.ts
260295 sed -i '' 's/waitforTimeout: [0-9]*/waitforTimeout: 60000/' wdio.conf.ts
261296
297+ # Update device name to match the booted simulator
298+ echo "Updating wdio.conf.ts to use simulator: $SIMULATOR_NAME"
299+ sed -i '' "s/'appium:deviceName': '[^']*'/'appium:deviceName': '$SIMULATOR_NAME'/" wdio.conf.ts
300+ sed -i '' "s/\"appium:deviceName\": \"[^\"]*\"/\"appium:deviceName\": \"$SIMULATOR_NAME\"/" wdio.conf.ts
301+
302+ # Verify the change was made
303+ echo "Updated wdio.conf.ts device name:"
304+ grep -n "deviceName" wdio.conf.ts
305+
262306 # Add Appium capabilities to help with simulator boot issues
263307 sed -i '' 's/"appium:autoAcceptAlerts": true/"appium:autoAcceptAlerts": true,\n "appium:newCommandTimeout": 300,\n "appium:commandTimeouts": {"implicit": 30000},\n "appium:launchTimeout": 300000,\n "appium:deviceReadyTimeout": 300000,\n "appium:autoLaunch": false/' wdio.conf.ts
264308
0 commit comments