Skip to content

test: build ci

test: build ci #22

Workflow file for this run

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 (>= 17.0)
id: pick_ios
shell: bash
run: |
set -euo pipefail
MIN_IOS="17.0"
# 설치된 iOS Simulator 런타임 버전들 추출 (예: 17.2, 18.0 ...)
# 출력 포맷이 달라질 수 있어, "iOS <version>" 패턴에서 숫자만 뽑습니다.
versions=()
while IFS= read -r v; do
versions+=("$v")
done < <(
xcrun simctl runtime list 2>/dev/null \
| grep -Eo 'iOS ([0-9]+(\.[0-9]+)?)' \
| awk '{print $2}' \
| sort -V \
| uniq
)
if [ "${#versions[@]}" -eq 0 ]; then
echo "No iOS simulator runtimes detected." >&2
exit 1
fi
# MIN_IOS 이상 중 가장 낮은 버전 선택 (우선 MIN_IOS)
if printf '%s\n' "${versions[@]}" | grep -qx "$MIN_IOS"; then
chosen="$MIN_IOS"
else
chosen=$(printf '%s\n' "${versions[@]}" | awk -v min="$MIN_IOS" '$0+0 >= min+0 {print}' | sort -V | head -n 1 || true)
fi
if [ -z "${chosen:-}" ]; then
echo "No iOS runtime >= ${MIN_IOS} found. Available: ${versions[*]}" >&2
exit 1
fi
echo "Detected runtimes: ${versions[*]:-<none>}"
echo "Chosen iOS runtime version: $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_NAME=$(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", ""):
print(d["name"])
sys.exit(0)
sys.exit(1)
PY
)
if [ -z "${DEVICE_NAME:-}" ]; 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