Skip to content

Commit 56cb158

Browse files
committed
Update build.yml
1 parent 5de0ff8 commit 56cb158

1 file changed

Lines changed: 50 additions & 27 deletions

File tree

.github/workflows/build.yml

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,48 @@ jobs:
2828
run: |
2929
set -euo pipefail
3030
31-
# 설치된 iOS Simulator 런타임 버전들 추출
32-
# 출력 포맷이 달라질 수 있어, "iOS <version>" 패턴에서 숫자만 뽑습니다.
33-
versions=()
34-
while IFS= read -r v; do
35-
versions+=("$v")
36-
done < <(
37-
xcrun simctl runtime list 2>/dev/null \
38-
| grep -Eo 'iOS ([0-9]+(\.[0-9]+)*)' \
39-
| awk '{print $2}' \
40-
| sort -V \
41-
| uniq
31+
# iPhone 시뮬레이터가 존재하는 런타임 중 가장 낮은 버전 선택 (패치 버전 포함)
32+
chosen=$(python3 - <<'PY'
33+
import json, re, subprocess
34+
35+
runtime_text = subprocess.check_output(["xcrun", "simctl", "runtime", "list"], text=True, stderr=subprocess.DEVNULL)
36+
versions = re.findall(r'iOS ([0-9]+(?:\.[0-9]+)*)', runtime_text)
37+
38+
def ver_key(v):
39+
return [int(x) for x in v.split(".")]
40+
41+
versions = sorted(set(versions), key=ver_key)
42+
43+
devices = json.loads(subprocess.check_output(["xcrun", "simctl", "list", "devices", "-j"], text=True)).get("devices", {})
44+
45+
def is_available(d):
46+
return d.get("isAvailable") or d.get("availability") == "(available)"
47+
48+
def has_iphone(version):
49+
prefix = f"com.apple.CoreSimulator.SimRuntime.iOS-{version.replace('.', '-') }"
50+
for runtime, devs in devices.items():
51+
if not runtime.startswith(prefix):
52+
continue
53+
for d in devs:
54+
if is_available(d) and "iPhone" in d.get("name", ""):
55+
return True
56+
return False
57+
58+
for v in versions:
59+
if has_iphone(v):
60+
print(v)
61+
raise SystemExit(0)
62+
63+
raise SystemExit(1)
64+
PY
4265
)
4366
44-
if [ "${#versions[@]}" -eq 0 ]; then
45-
echo "No iOS simulator runtimes detected." >&2
67+
if [ -z "${chosen:-}" ]; then
68+
echo "No iPhone simulator runtimes detected." >&2
4669
exit 1
4770
fi
4871
49-
# 실제 존재하는 런타임 중 가장 낮은 버전 선택
50-
MIN_IOS="${versions[0]}"
51-
chosen="$MIN_IOS"
52-
53-
echo "Detected runtimes: ${versions[*]:-<none>}"
54-
echo "Chosen iOS runtime version: $chosen"
72+
echo "Chosen iOS runtime version (iPhone): $chosen"
5573
5674
echo "ios_version=$chosen" >> "$GITHUB_OUTPUT"
5775
@@ -70,18 +88,23 @@ jobs:
7088
# 선택된 iOS 런타임에서 'iPhone'이 포함된 첫 번째 시뮬레이터 이름 선택 (JSON 파싱)
7189
DEVICE_INFO=$(python3 - <<'PY'
7290
import json, os, subprocess, sys
91+
7392
ios_ver = os.environ['IOS_VER']
7493
prefix = f"com.apple.CoreSimulator.SimRuntime.iOS-{ios_ver.replace('.', '-') }"
75-
data = subprocess.check_output(["xcrun", "simctl", "list", "devices", "available", "-j"], text=True)
94+
data = subprocess.check_output(["xcrun", "simctl", "list", "devices", "-j"], text=True)
7695
j = json.loads(data)
96+
97+
def is_available(d):
98+
return d.get("isAvailable") or d.get("availability") == "(available)"
99+
77100
for runtime, devices in j.get("devices", {}).items():
78-
if not runtime.startswith(prefix):
79-
continue
80-
for d in devices:
81-
if d.get("isAvailable") and "iPhone" in d.get("name", ""):
82-
os_ver = runtime.split("iOS-")[-1].replace("-", ".")
83-
print(f"{d['name']}|{os_ver}")
84-
sys.exit(0)
101+
if not runtime.startswith(prefix):
102+
continue
103+
for d in devices:
104+
if is_available(d) and "iPhone" in d.get("name", ""):
105+
os_ver = runtime.split("iOS-")[-1].replace("-", ".")
106+
print(f"{d['name']}|{os_ver}")
107+
sys.exit(0)
85108
sys.exit(1)
86109
PY
87110
)

0 commit comments

Comments
 (0)