-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (98 loc) · 3.88 KB
/
build.yml
File metadata and controls
122 lines (98 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: iOS CI
on:
pull_request:
env:
SCHEME: DevLog
permissions:
contents: read
issues: write
pull-requests: write
jobs:
build:
runs-on: macos-14 # iOS 17 시뮬레이터 런타임 포함
steps:
- uses: actions/checkout@v4
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest
- name: Select iOS Simulator Runtime (installed)
id: pick_ios
shell: bash
run: |
set -euo pipefail
# iPhone 시뮬레이터가 존재하는 런타임 중 가장 낮은 버전 선택 (패치 버전 포함)
chosen=$(python3 - <<'PY'
import json, re, subprocess
runtime_text = subprocess.check_output(["xcrun", "simctl", "runtime", "list"], text=True, stderr=subprocess.DEVNULL)
versions = re.findall(r'iOS ([0-9]+(?:\.[0-9]+)*)', runtime_text)
def ver_key(v):
return [int(x) for x in v.split(".")]
versions = sorted(set(versions), key=ver_key)
devices = json.loads(subprocess.check_output(["xcrun", "simctl", "list", "devices", "available", "-j"], text=True)).get("devices", {})
def has_iphone(version):
prefix = f"com.apple.CoreSimulator.SimRuntime.iOS-{version.replace('.', '-') }"
for runtime, devs in devices.items():
if not runtime.startswith(prefix):
continue
for d in devs:
if d.get("isAvailable") and "iPhone" in d.get("name", ""):
return True
return False
for v in versions:
if has_iphone(v):
print(v)
raise SystemExit(0)
raise SystemExit(1)
PY
)
if [ -z "${chosen:-}" ]; then
echo "No iPhone simulator runtimes detected." >&2
exit 1
fi
echo "Chosen iOS runtime version (iPhone): $chosen"
echo "ios_version=$chosen" >> "$GITHUB_OUTPUT"
- name: Build
shell: bash
run: |
set -euo pipefail
set -x
IOS_VER="${{ steps.pick_ios.outputs.ios_version }}"
export IOS_VER
xcodebuild -version
echo "Using scheme: $SCHEME"
# 선택된 iOS 런타임에서 'iPhone'이 포함된 첫 번째 시뮬레이터 이름 선택 (JSON 파싱)
DEVICE_INFO=$(python3 - <<'PY'
import json, os, subprocess, sys
ios_ver = os.environ['IOS_VER']
prefix = f"com.apple.CoreSimulator.SimRuntime.iOS-{ios_ver.replace('.', '-') }"
data = subprocess.check_output(["xcrun", "simctl", "list", "devices", "available", "-j"], text=True)
j = json.loads(data)
for runtime, devices in j.get("devices", {}).items():
if not runtime.startswith(prefix):
continue
for d in devices:
if d.get("isAvailable") and "iPhone" in d.get("name", ""):
os_ver = runtime.split("iOS-")[-1].replace("-", ".")
print(f"{d['name']}|{os_ver}")
sys.exit(0)
sys.exit(1)
PY
)
IFS='|' read -r DEVICE_NAME DEVICE_OS <<< "$DEVICE_INFO"
IOS_VER="$DEVICE_OS"
export IOS_VER
if [ -z "${DEVICE_NAME:-}" ] || [ -z "${IOS_VER:-}" ]; then
echo "No available simulator device found for iOS ${IOS_VER}." >&2
exit 1
fi
echo "Using simulator: $DEVICE_NAME (iOS ${IOS_VER})"
# 예시: 시뮬레이터 대상으로 빌드/테스트 시 destination에서 OS 지정
set -o pipefail
xcodebuild \
-scheme "$SCHEME" \
-configuration Debug \
-destination "platform=iOS Simulator,OS=${IOS_VER},name=${DEVICE_NAME}" \
-showBuildTimingSummary \
build \
| cat