Skip to content

Commit 6042951

Browse files
committed
Improve simulator discoverability
1 parent 654516f commit 6042951

5 files changed

Lines changed: 43 additions & 10 deletions

File tree

sample/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ ruby ">= 2.6.10"
66
gem 'cocoapods', '1.16.2'
77
gem 'cocoapods-check', '1.1.0'
88
gem 'activesupport', '>= 6.1.7.5', '< 7.3.0'
9+
gem 'xcpretty'

sample/Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ GEM
9292
nkf (0.2.0)
9393
public_suffix (4.0.7)
9494
rexml (3.4.1)
95+
rouge (3.28.0)
9596
ruby-macho (2.5.1)
9697
securerandom (0.4.1)
9798
typhoeus (1.4.1)
@@ -105,6 +106,8 @@ GEM
105106
colored2 (~> 3.1)
106107
nanaimo (~> 0.4.0)
107108
rexml (>= 3.3.6, < 4.0)
109+
xcpretty (0.4.1)
110+
rouge (~> 3.28.0)
108111

109112
PLATFORMS
110113
ruby
@@ -113,6 +116,7 @@ DEPENDENCIES
113116
activesupport (>= 6.1.7.5, < 7.3.0)
114117
cocoapods (= 1.16.2)
115118
cocoapods-check (= 1.1.0)
119+
xcpretty
116120

117121
RUBY VERSION
118122
ruby 3.1.2p20

sample/scripts/build_ios

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
set -ex
44
set -eo pipefail
55

6-
if [[ -n $CURRENT_SIMULATOR_UUID ]]; then
7-
dest="id=$CURRENT_SIMULATOR_UUID"
8-
else
9-
dest="platform=iOS Simulator,name=iPhone 15 Pro"
10-
fi
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
source "$SCRIPT_DIR/simulator"
8+
dest="$(get_sim_destination)"
119

1210
cd ios
1311

sample/scripts/simulator

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
# Determine an iOS Simulator destination string for xcodebuild.
4+
get_sim_destination() {
5+
if [[ -n "$CURRENT_SIMULATOR_UUID" ]]; then
6+
echo "id=$CURRENT_SIMULATOR_UUID"
7+
return
8+
fi
9+
10+
# Prefer a currently booted iOS simulator (iPhone or iPad)
11+
local udid
12+
udid="$(xcrun simctl list devices booted \
13+
| grep -E 'iPhone|iPad' \
14+
| sed -n -E 's/.*\(([0-9A-Fa-f-]{36})\).*/\1/p' \
15+
| head -n1)"
16+
17+
# If none booted, pick the first available iOS simulator (iPhone or iPad)
18+
if [[ -z "$udid" ]]; then
19+
udid="$(xcrun simctl list devices available \
20+
| grep -E 'iPhone|iPad' \
21+
| sed -n -E 's/.*\(([0-9A-Fa-f-]{36})\).*/\1/p' \
22+
| head -n1)"
23+
fi
24+
25+
if [[ -n "$udid" ]]; then
26+
echo "id=$udid"
27+
else
28+
echo "platform=iOS Simulator,name=iPhone 15 Pro"
29+
fi
30+
}
31+
32+

sample/scripts/test_ios

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
set -ex
44
set -eo pipefail
55

6-
if [[ -n $CURRENT_SIMULATOR_UUID ]]; then
7-
dest="id=$CURRENT_SIMULATOR_UUID"
8-
else
9-
dest="platform=iOS Simulator,name=iPhone 15 Pro"
10-
fi
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
source "$SCRIPT_DIR/simulator"
8+
dest="$(get_sim_destination)"
119

1210
cd ios
1311

0 commit comments

Comments
 (0)