Skip to content

Commit d6e8420

Browse files
Add platform-specific start scripts to dev.yml (#358)
This PR adds namespaced start commands for all sub-platforms under dev.yml: - `dev swift start`: Generates project and runs target compilation for booted simulator (or falls back to available iPhone). <img width="831" height="316" alt="image" src="https://github.com/user-attachments/assets/b87a8160-0cd3-4bd6-bab8-e32642140a97" /> - `dev android start`: Builds and installs CheckoutKitAndroidDemo app on active emulator. <img width="961" height="285" alt="image" src="https://github.com/user-attachments/assets/902ae3bf-3196-45dd-8daf-cab3053d871b" /> - `dev react-native start`: Launches Metro server with cache reset (backward-compatible). <img width="974" height="369" alt="image" src="https://github.com/user-attachments/assets/1508634a-7c14-4301-9c1a-2e6702259ebf" /> - `dev web start`: Starts local dev server (backward-compatible). <img width="1341" height="334" alt="image" src="https://github.com/user-attachments/assets/59e2e44c-6f97-4f39-93d4-a1043a2916e2" /> Also resolves an Xcode target compilation issue where get_device_id would previously select unavailable simulator profiles.
1 parent 80f3ec5 commit d6e8420

3 files changed

Lines changed: 43 additions & 8 deletions

File tree

dev.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ commands:
172172
desc: Build all sample applications
173173
run: cd platforms/android/samples/MobileBuyIntegration && ./gradlew build
174174

175+
start:
176+
desc: Build the android sample app and install it to the booted emulator
177+
run: cd platforms/android/samples/CheckoutKitAndroidDemo && ./gradlew installDebug
178+
175179
test:
176180
desc: Run all tests with clean build
177181
run: cd platforms/android && ./gradlew clean test --console=plain
@@ -284,6 +288,23 @@ commands:
284288
samples:
285289
desc: Build all sample applications to verify integration
286290
run: cd platforms/swift && ./Scripts/build_samples
291+
292+
start:
293+
desc: Build the swift sample app for the booted simulator (preferably)
294+
run: |
295+
set -e
296+
cd platforms/swift
297+
./Scripts/generate_xcode_projects
298+
# Automatically detect if a booted simulator exists, otherwise fallback to default
299+
BOOTED_ID=$(xcrun simctl list devices booted | grep -E 'iPhone|iPad|Air' | sed -n -E 's/.*\(([0-9A-Fa-f-]{36})\).*/\1/p' | head -n1 || true)
300+
if [ -n "$BOOTED_ID" ]; then
301+
export CURRENT_SIMULATOR_UUID="$BOOTED_ID"
302+
echo "Using booted simulator: $BOOTED_ID"
303+
else
304+
echo "No booted simulator found. Falling back to default simulator."
305+
fi
306+
cd Samples
307+
../Scripts/xcode_run build CheckoutKitSwiftDemo
287308
test:
288309
desc: |
289310
`dev swift test` - Run all tests for the ShopifyCheckoutKit-Package.
@@ -474,9 +495,9 @@ commands:
474495
fi
475496
echo "Cleaned root, module and sample workspaces"
476497
477-
server:
498+
start:
478499
desc: Start Metro development server
479-
aliases: [s]
500+
aliases: [s, server]
480501
run: cd platforms/react-native && pnpm sample start --reset-cache
481502

482503
ios:
@@ -603,10 +624,14 @@ commands:
603624
desc: Remove dist and coverage directories
604625
run: cd platforms/web && pnpm clean
605626

606-
sample:
627+
start:
607628
desc: Start the sample app dev server
608629
aliases: [s]
609630
run: cd platforms/web && pnpm sample
631+
632+
sample:
633+
desc: Start the sample app dev server
634+
run: cd platforms/web && pnpm sample
610635
subcommands:
611636
build:
612637
desc: Build the sample app

platforms/swift/Scripts/get_device_id

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fi
2121
# List all devices and filter
2222
if [ -n "$SEARCH" ]; then
2323
# Create a search string with spaces to match exact model (case insensitive)
24-
DEVICES=$(xcrun simctl list devices | grep -i "$DEVICE_TYPE")
24+
DEVICES=$(xcrun simctl list devices | grep -v -i "unavailable" | grep -i "$DEVICE_TYPE")
2525

2626
# Use grep to find lines containing all search terms (case insensitive)
2727
for term in $SEARCH; do
@@ -32,7 +32,7 @@ if [ -n "$SEARCH" ]; then
3232
DEVICE_ID=$(echo "$DEVICES" | head -1 | sed -E 's/.*\(([A-Z0-9-]+)\).*/\1/')
3333
else
3434
# If no model specified, get the first device of the type (case insensitive)
35-
DEVICE_ID=$(xcrun simctl list devices | grep -i "$DEVICE_TYPE" | head -1 | sed -E 's/.*\(([A-Z0-9-]+)\).*/\1/')
35+
DEVICE_ID=$(xcrun simctl list devices | grep -v -i "unavailable" | grep -i "$DEVICE_TYPE" | head -1 | sed -E 's/.*\(([A-Z0-9-]+)\).*/\1/')
3636
fi
3737

3838
# Check if identifier was found

platforms/swift/Scripts/xcode_run

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,19 @@ fi
2222
if [[ -n $CURRENT_SIMULATOR_UUID ]]; then
2323
dest="id=$CURRENT_SIMULATOR_UUID"
2424
else
25-
# Get a valid iPhone simulator ID using get_device_id.sh
26-
DEVICE_ID=$("$SCRIPT_DIR/get_device_id" "iPhone 16")
27-
dest="id=$DEVICE_ID"
25+
# Prefer a currently booted iOS simulator (iPhone, iPad, Air, etc.)
26+
BOOTED_ID=$(xcrun simctl list devices booted | grep -v -i "unavailable" | grep -E 'iPhone|iPad|Air' | sed -n -E 's/.*\(([0-9A-Fa-f-]{36})\).*/\1/p' | head -n1 || true)
27+
if [[ -n "$BOOTED_ID" ]]; then
28+
dest="id=$BOOTED_ID"
29+
else
30+
# Fallback to get_device_id
31+
DEVICE_ID=$("$SCRIPT_DIR/get_device_id" "iPhone 16" 2>/dev/null || "$SCRIPT_DIR/get_device_id" "iPhone" 2>/dev/null || true)
32+
if [[ -n "$DEVICE_ID" ]]; then
33+
dest="id=$DEVICE_ID"
34+
else
35+
dest="platform=iOS Simulator,name=iPhone 15 Pro"
36+
fi
37+
fi
2838
fi
2939

3040
xcodebuild_cmd="xcodebuild $ACTION -scheme $SCHEME -sdk iphonesimulator -destination \"$dest\" -skipPackagePluginValidation -disableAutomaticPackageResolution"

0 commit comments

Comments
 (0)