@@ -37,144 +37,10 @@ jobs:
3737 restore-keys : |
3838 ${{ runner.os }}-spm-
3939
40-
41- - name : Select iOS Simulator Runtime (installed)
42- id : pick_ios
43- shell : bash
44- run : |
45- set -euo pipefail
46-
47- # macOS 메인 버전에 맞는 iOS 버전 중 최신 버전의 iPhone 선택
48- RESULT=$(python3 - <<'PY'
49- import re, subprocess, sys
50-
51- xcode_ver = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()[0].strip()
52- xcode_major = xcode_ver.split()[1].split('.')[0]
53- try:
54- xcode_major_num = int(xcode_major)
55- except ValueError:
56- xcode_major_num = None
57- if xcode_major_num is not None and xcode_major_num <= 15:
58- xcode_major = "26"
59-
60- text = subprocess.check_output(["xcrun", "simctl", "list", "devices"], text=True)
61- lines = text.splitlines()
62-
63- def ver_key(v):
64- return tuple(int(x) for x in v.split('.'))
65-
66- # 1) 최신 iOS 버전(해당 mac 메이저) 찾기
67- latest_ver = None
68- for line in lines:
69- header = re.match(r"^-- iOS ([0-9]+(?:\.[0-9]+)*) --$", line.strip())
70- if not header:
71- continue
72- ver = header.group(1)
73- if not ver.startswith(f"{xcode_major}."):
74- continue
75- if latest_ver is None or ver_key(ver) > ver_key(latest_ver):
76- latest_ver = ver
77-
78- if latest_ver is None:
79- print(f"No iOS versions found for Xcode major {xcode_major}", file=sys.stderr)
80- sys.exit(1)
81-
82- # 2) 해당 버전 섹션에서 첫 iPhone 찾고 즉시 종료
83- current_ver = None
84- for line in lines:
85- header = re.match(r"^-- iOS ([0-9]+(?:\.[0-9]+)*) --$", line.strip())
86- if header:
87- current_ver = header.group(1)
88- continue
89- if current_ver != latest_ver:
90- continue
91- if "(unavailable)" in line:
92- continue
93- if "iPhone" in line:
94- raw = line.strip()
95- # key:value 형태면 딕셔너리로 파싱해서 name만 사용
96- if "platform:" in raw and "name:" in raw and "OS:" in raw:
97- kv = {}
98- for part in raw.split(","):
99- if ":" not in part:
100- continue
101- k, v = part.split(":", 1)
102- kv[k.strip()] = v.strip()
103- name = kv.get("name", raw)
104- else:
105- name = raw
106- # UUID/상태만 제거하고 모델명 괄호는 유지
107- name = re.sub(r"\s+\([0-9A-Fa-f-]{36}\)\s+\(.*\)$", "", name)
108- print(f"{latest_ver}|{name}")
109- sys.exit(0)
110-
111- print(f"No iPhone candidates found for iOS {latest_ver}", file=sys.stderr)
112- sys.exit(1)
113- PY
114- )
115-
116- if [ -z "${RESULT:-}" ]; then
117- echo "No iPhone simulator devices detected." >&2
118- exit 1
119- fi
120-
121- IFS='|' read -r IOS_VER DEVICE_NAME <<< "$RESULT"
122-
123- echo "Chosen iOS runtime version (iPhone): $IOS_VER"
124- echo "Chosen simulator: $DEVICE_NAME"
125-
126- echo "ios_version=$IOS_VER" >> "$GITHUB_OUTPUT"
127- echo "device_name=$DEVICE_NAME" >> "$GITHUB_OUTPUT"
128-
12940 - name : Build
130- shell : bash
131- run : |
132- set -euo pipefail
133- set -x
134- IOS_VER="${{ steps.pick_ios.outputs.ios_version }}"
135- DEVICE_NAME="${{ steps.pick_ios.outputs.device_name }}"
136- SPM_DIR="$GITHUB_WORKSPACE/.spm"
137- mkdir -p "$SPM_DIR"
138-
139- xcodebuild -version
140-
141- echo "Using scheme: $SCHEME"
142-
143- echo "Using simulator: $DEVICE_NAME (iOS ${IOS_VER})"
144-
145- set -o pipefail
146- set +e
147- echo "== Resolving Swift Package dependencies =="
148- xcodebuild \
149- -scheme "$SCHEME" \
150- -configuration Debug \
151- -clonedSourcePackagesDirPath "$SPM_DIR" \
152- -resolvePackageDependencies
153- echo "== Starting xcodebuild build =="
154- xcodebuild \
155- -scheme "$SCHEME" \
156- -configuration Debug \
157- -destination "platform=iOS Simulator,OS=${IOS_VER},name=${DEVICE_NAME}" \
158- -clonedSourcePackagesDirPath "$SPM_DIR" \
159- -skipPackagePluginValidation \
160- -skipMacroValidation \
161- -showBuildTimingSummary \
162- build \
163- | tee build.log
164- echo "== xcodebuild finished =="
165- XC_STATUS=${PIPESTATUS[0]}
166- set -e
167-
168- if [ -f build.log ]; then
169- echo "== error: lines =="
170- if grep -i "error:" build.log; then
171- if [ "$XC_STATUS" -eq 0 ]; then
172- XC_STATUS=1
173- fi
174- fi
175- fi
176-
177- exit $XC_STATUS
41+ uses : ./.github/actions/ios-simulator-build
42+ with :
43+ scheme : ${{ env.SCHEME }}
17844
17945 - name : Comment build failure on PR
18046 if : failure() && github.event.pull_request.head.repo.fork == false
0 commit comments