@@ -28,43 +28,30 @@ jobs:
2828 run : |
2929 set -euo pipefail
3030
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- def ver_key(v):
38- return [int(x) for x in v.split(".")]
39- versions = sorted(set(versions), key=ver_key)
40-
41- devices = json.loads(subprocess.check_output(["xcrun", "simctl", "list", "devices", "available", "-j"], text=True)).get("devices", {})
42-
43- def has_iphone(version):
44- prefix = f"com.apple.CoreSimulator.SimRuntime.iOS-{version.replace('.', '-') }"
45- for runtime, devs in devices.items():
46- if not runtime.startswith(prefix):
47- continue
48- for d in devs:
49- if d.get("isAvailable") and "iPhone" in d.get("name", ""):
50- return True
51- return False
52-
53- for v in versions:
54- if has_iphone(v):
55- print(v)
56- raise SystemExit(0)
57-
58- raise SystemExit(1)
59- PY
60- )
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
42+ )
6143
62- if [ -z "${chosen:-}" ]; then
63- echo "No iPhone simulator runtimes detected." >&2
44+ if [ "${#versions[@]}" -eq 0 ]; then
45+ echo "No iOS simulator runtimes detected." >&2
6446 exit 1
6547 fi
6648
67- echo "Chosen iOS runtime version (iPhone): $chosen"
49+ # 실제 존재하는 런타임 중 가장 낮은 버전 선택
50+ MIN_IOS="${versions[0]}"
51+ chosen="$MIN_IOS"
52+
53+ echo "Detected runtimes: ${versions[*]:-<none>}"
54+ echo "Chosen iOS runtime version: $chosen"
6855
6956 echo "ios_version=$chosen" >> "$GITHUB_OUTPUT"
7057
@@ -83,19 +70,18 @@ jobs:
8370 # 선택된 iOS 런타임에서 'iPhone'이 포함된 첫 번째 시뮬레이터 이름 선택 (JSON 파싱)
8471 DEVICE_INFO=$(python3 - <<'PY'
8572 import json, os, subprocess, sys
86-
8773 ios_ver = os.environ['IOS_VER']
8874 prefix = f"com.apple.CoreSimulator.SimRuntime.iOS-{ios_ver.replace('.', '-') }"
8975 data = subprocess.check_output(["xcrun", "simctl", "list", "devices", "available", "-j"], text=True)
9076 j = json.loads(data)
9177 for runtime, devices in j.get("devices", {}).items():
92- if not runtime.startswith(prefix):
93- continue
94- for d in devices:
95- if d.get("isAvailable") and "iPhone" in d.get("name", ""):
96- os_ver = runtime.split("iOS-")[-1].replace("-", ".")
97- print(f"{d['name']}|{os_ver}")
98- sys.exit(0)
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)
9985 sys.exit(1)
10086 PY
10187 )
0 commit comments