-
Notifications
You must be signed in to change notification settings - Fork 0
[#255] fastlane 배포 시 빌드 자동화를 우선 시행하도록 한다 #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
07acdec
e6142b7
44ab651
250fa9f
23debb7
2cdf6c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| name: iOS Simulator Build | ||
| description: Select an installed iOS simulator runtime and build the app with xcodebuild. | ||
|
|
||
| inputs: | ||
| scheme: | ||
| description: Xcode scheme to build | ||
| required: true | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Select iOS Simulator Runtime (installed) | ||
| id: pick_ios | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| # macOS 메인 버전에 맞는 iOS 버전 중 최신 버전의 iPhone 선택 | ||
| RESULT=$(python3 - <<'PY' | ||
| import re, subprocess, sys | ||
|
|
||
| xcode_ver = subprocess.check_output(["xcodebuild", "-version"], text=True).splitlines()[0].strip() | ||
| xcode_major = xcode_ver.split()[1].split('.')[0] | ||
| try: | ||
| xcode_major_num = int(xcode_major) | ||
| except ValueError: | ||
| xcode_major_num = None | ||
| if xcode_major_num is not None and xcode_major_num <= 15: | ||
| xcode_major = "26" | ||
|
|
||
| text = subprocess.check_output(["xcrun", "simctl", "list", "devices"], text=True) | ||
| lines = text.splitlines() | ||
|
|
||
| def ver_key(v): | ||
| return tuple(int(x) for x in v.split('.')) | ||
|
|
||
| # 1) 최신 iOS 버전(해당 mac 메이저) 찾기 | ||
| latest_ver = None | ||
| for line in lines: | ||
| header = re.match(r"^-- iOS ([0-9]+(?:\.[0-9]+)*) --$", line.strip()) | ||
| if not header: | ||
| continue | ||
| ver = header.group(1) | ||
| if not ver.startswith(f"{xcode_major}."): | ||
| continue | ||
| if latest_ver is None or ver_key(ver) > ver_key(latest_ver): | ||
| latest_ver = ver | ||
|
|
||
| if latest_ver is None: | ||
| print(f"No iOS versions found for Xcode major {xcode_major}", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| # 2) 해당 버전 섹션에서 첫 iPhone 찾고 즉시 종료 | ||
| current_ver = None | ||
| for line in lines: | ||
| header = re.match(r"^-- iOS ([0-9]+(?:\.[0-9]+)*) --$", line.strip()) | ||
| if header: | ||
| current_ver = header.group(1) | ||
| continue | ||
| if current_ver != latest_ver: | ||
| continue | ||
| if "(unavailable)" in line: | ||
| continue | ||
| if "iPhone" in line: | ||
| raw = line.strip() | ||
| # key:value 형태면 딕셔너리로 파싱해서 name만 사용 | ||
| if "platform:" in raw and "name:" in raw and "OS:" in raw: | ||
| kv = {} | ||
| for part in raw.split(","): | ||
| if ":" not in part: | ||
| continue | ||
| k, v = part.split(":", 1) | ||
| kv[k.strip()] = v.strip() | ||
| name = kv.get("name", raw) | ||
| else: | ||
| name = raw | ||
| # UUID/상태만 제거하고 모델명 괄호는 유지 | ||
| name = re.sub(r"\s+\([0-9A-Fa-f-]{36}\)\s+\(.*\)$", "", name) | ||
| print(f"{latest_ver}|{name}") | ||
| sys.exit(0) | ||
|
|
||
| print(f"No iPhone candidates found for iOS {latest_ver}", file=sys.stderr) | ||
| sys.exit(1) | ||
| PY | ||
| ) | ||
|
|
||
| if [ -z "${RESULT:-}" ]; then | ||
| echo "No iPhone simulator devices detected." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| IFS='|' read -r IOS_VER DEVICE_NAME <<< "$RESULT" | ||
|
|
||
| echo "Chosen iOS runtime version (iPhone): $IOS_VER" | ||
| echo "Chosen simulator: $DEVICE_NAME" | ||
|
|
||
| echo "ios_version=$IOS_VER" >> "$GITHUB_OUTPUT" | ||
| echo "device_name=$DEVICE_NAME" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Build | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| set -x | ||
| IOS_VER="${{ steps.pick_ios.outputs.ios_version }}" | ||
| DEVICE_NAME="${{ steps.pick_ios.outputs.device_name }}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The GitHub Action uses expressions like |
||
| SPM_DIR="$GITHUB_WORKSPACE/.spm" | ||
| mkdir -p "$SPM_DIR" | ||
|
|
||
| xcodebuild -version | ||
|
|
||
| echo "Using scheme: ${{ inputs.scheme }}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The GitHub Action uses the expression Example: - name: Build
shell: bash
env:
SCHEME: ${{ inputs.scheme }}
run: |
xcodebuild -scheme "$SCHEME" ... |
||
|
|
||
| echo "Using simulator: $DEVICE_NAME (iOS ${IOS_VER})" | ||
|
|
||
| set -o pipefail | ||
| set +e | ||
| echo "== Resolving Swift Package dependencies ==" | ||
| xcodebuild \ | ||
| -scheme "${{ inputs.scheme }}" \ | ||
| -configuration Debug \ | ||
| -clonedSourcePackagesDirPath "$SPM_DIR" \ | ||
| -resolvePackageDependencies | ||
| echo "== Starting xcodebuild build ==" | ||
| xcodebuild \ | ||
| -scheme "${{ inputs.scheme }}" \ | ||
| -configuration Debug \ | ||
| -destination "platform=iOS Simulator,OS=${IOS_VER},name=${DEVICE_NAME}" \ | ||
| -clonedSourcePackagesDirPath "$SPM_DIR" \ | ||
| -skipPackagePluginValidation \ | ||
| -skipMacroValidation \ | ||
| -showBuildTimingSummary \ | ||
| build \ | ||
| | tee build.log | ||
| echo "== xcodebuild finished ==" | ||
| XC_STATUS=${PIPESTATUS[0]} | ||
| set -e | ||
|
|
||
| if [ -f build.log ]; then | ||
| echo "== error: lines ==" | ||
| if grep -i "error:" build.log; then | ||
| if [ "$XC_STATUS" -eq 0 ]; then | ||
| XC_STATUS=1 | ||
| fi | ||
| fi | ||
| fi | ||
|
|
||
| exit $XC_STATUS | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS 시뮬레이터 버전을 선택하는 Python 스크립트 로직에 문제가 있어, 의도와 다르게 동작하여 시뮬레이터를 찾지 못하고 실패할 수 있습니다.
xcodebuild -version으로 얻은 Xcode 메이저 버전(예: 15)과simctl이 목록으로 보여주는 iOS SDK 버전(예: 17.2)은 직접적인 숫자 연관성이 없습니다.xcode_major를 특정 조건에서"26"으로 하드코딩하는 부분은 iOS 버전 규칙과 맞지 않아 원하는 결과를 얻기 어렵습니다.xcrun simctl list devices는 현재 Xcode 환경에서 사용 가능한 시뮬레이터 목록을 보여주므로, 복잡한 버전 확인 없이 목록에서 가장 최신 버전의 iOS 시뮬레이터를 선택하는 것이 더 간단하고 안정적인 방법입니다. 아래와 같이 스크립트를 수정하는 것을 제안합니다.