Skip to content

test: build ci

test: build ci #28

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 (installed)
id: pick_ios
shell: bash
run: |
set -euo pipefail
# iPhone 시뮬레이터가 존재하는 런타임 중 가장 낮은 버전 선택
chosen=$(python3 - <<'PY'
import json, subprocess
data = subprocess.check_output(["xcrun", "simctl", "list", "devices", "available", "-j"], text=True)
j = json.loads(data)
versions = []
for runtime, devices in j.get("devices", {}).items():
if "iOS-" not in runtime:
continue
# iPhone 디바이스가 있는 런타임만
if not any(d.get("isAvailable") and "iPhone" in d.get("name", "") for d in devices):
continue
ver = runtime.split("iOS-")[-1].replace("-", ".")
versions.append(ver)
def ver_key(v):
return [int(x) for x in v.split(".")]
versions = sorted(set(versions), key=ver_key)
if not versions:
raise SystemExit(1)
print(versions[0])
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