# airbuild-xcode

> AirBuild 빌드 스크립트 안에서 xcodebuild install, archive, test를 실행합니다. 구성, 대상, 서명, 캐시에는 AirBuild 기본값이 적용됩니다.

Source: https://air.build/ko/docs/cli/airbuild-xcode/

`airbuild-xcode`는 동작 하나로 `xcodebuild`를 한 번 호출하며, 넘기지 않은 값에는 AirBuild 기본값을 채워 넣습니다. 클라우드 macOS 빌더나 Mac 팀의 Mac에서 `runbuild`, `runtest`, `runmacos`가 실행하는 스크립트(그 스크립트가 호출하는 스크립트 포함) 안에서만 존재합니다. 다른 곳에는 설치되어 있지 않으며 Linux 빌더에도 없습니다.

`install`, `archive`, `test`, `-showBuildSettings`에는 `xcodebuild` 대신 이것을 쓰세요. 그 밖의 Xcode 작업에는 `xcodebuild`를 직접 호출하세요.

## 개요

```bash
airbuild-xcode install|archive|test|-showBuildSettings [xcodebuild options and build settings]
airbuild-xcode --help
```

동작이 맨 앞에 와야 합니다. 나머지 인수는 모두 그대로 `xcodebuild`에 전달되며, `airbuild-xcode`는 `xcodebuild`의 종료 코드로 종료합니다.

## 동작

| 동작 | 용도 | 캐시 |
| --- | --- | --- |
| `install` | 일상적인 빌드: `xcodebuild install`이 스킴의 Archive 대상을 `DSTROOT`에 증분 빌드합니다. `build.script`에 넣으세요. | 클라우드 빌드에서는 실행의 첫 `install`이 프로젝트의 DerivedData를 되살립니다. |
| `archive` | 서명된 `.ipa`나 서명되지 않은 기기용 패키지를 만드는 아카이브. `release.script`에 넣으세요. | 없음: 아카이브는 매 실행 처음부터 시작합니다. |
| `test` | 테스트를 실행합니다. | 클라우드 빌드에서는 실행의 첫 `test`가 프로젝트의 DerivedData(`install`과는 별도의 사본)를 되살립니다. |
| `-showBuildSettings` | 빌드가 받을 것과 같은 기본값으로 빌드 설정을 출력합니다. | — |

서명된 빌드와 기기용 빌드는 아카이브를 내보내므로 `install`을 거부하고 `release:` 레시피를 실행합니다.

## 기본값

`install`, `archive`, `-showBuildSettings`는 `runbuild`가 설정하는 `AIRBUILD_SIGN`(기본값 `0`)을 따릅니다.

| 빌드 | 구성 | 대상 | 서명 |
| --- | --- | --- | --- |
| 일반(`AIRBUILD_SIGN=0`) | `Debug` | `generic/platform=iOS Simulator` | `CODE_SIGN_IDENTITY=-`. 프로젝트의 다른 서명 설정은 유지됩니다 |
| 기기용 패키지(`AIRBUILD_SIGN=0`, `AIRBUILD_DEVICE=1`): `runbuild --unsigned` 또는 관리형 서명 없는 **기기에 설치** | `Release` | `generic/platform=iOS` | 프로젝트의 entitlements로 애드혹 서명하며 팀이나 프로파일은 없습니다. 시뮬레이터용 `-destination`과 `-sdk` 값은 제거됩니다. |
| 서명(`AIRBUILD_SIGN=1`): `runbuild --sign` | `Release` | `generic/platform=iOS` | AirBuild가 준비한 관리형 서명 |

`test`의 기본 대상은 일반(폴더블이 아닌) iPhone이 있는 가장 최신 iOS 런타임의 iPhone 시뮬레이터이며, 이미 부팅된 것을 우선합니다. 여기에 `CODE_SIGN_IDENTITY=-`와 `-collect-test-diagnostics never`가 더해집니다. 시뮬레이터를 새로 만들지는 않습니다.

## 재정의할 수 있는 것

- 명시적인 `-configuration`, `-destination`(테스트에서는 여러 개 가능), 그리고 일반 빌드와 테스트에서는 `CODE_SIGN_IDENTITY=…`가 기본값을 대체합니다.
- `-collect-test-diagnostics on-failure`는 `test`에서 시뮬레이터 진단 수집을 다시 켭니다.
- 명령줄의 `ARCHS`, `COMPILATION_CACHE_*`, `SWIFT_ENABLE_PREFIX_MAPPING`, `CLANG_ENABLE_PREFIX_MAPPING`은 빌더의 플랫폼 설정보다 우선합니다. 빌더에서 시뮬레이터와 macOS 빌드는 `ARCHS`를 넘기지 않으면 arm64 전용입니다.
- 관리형 서명은 프로젝트, `-xcconfig`, 명령줄의 서명 설정을 재정의합니다: `CODE_SIGNING_ALLOWED`, `CODE_SIGNING_REQUIRED`, `CODE_SIGN_IDENTITY`, `CODE_SIGN_STYLE`, `DEVELOPMENT_TEAM`, `PROVISIONING_PROFILE`, `PROVISIONING_PROFILE_SPECIFIER`, `OTHER_CODE_SIGN_FLAGS`. `CODE_SIGN_ENTITLEMENTS`는 유지됩니다.

## 버전 번호

사람이 AirBuild 앱에서 시작한 기기용 또는 관리형 서명 아카이브는 프로젝트의 최소 버전까지 올라갑니다. `MARKETING_VERSION`과 `CURRENT_PROJECT_VERSION`은 소스의 값이 더 낮을 때에만 재정의됩니다. 에이전트가 시작한 빌드는 절대 올라가지 않으므로, 빌드 번호는 프로젝트에서 직접 설정하세요.

## 출력

`airbuild-xcode`는 `xcodebuild`를 실행하기 전에 무엇을 골랐는지 표준 오류에 출력합니다.

```text
[airbuild-xcode] sign=0; configuration=Debug (default); destination=generic/platform=iOS\ Simulator (default).
[airbuild-xcode] CODE_SIGN_IDENTITY=default (-); project signing settings are preserved.
```

```text
[airbuild-xcode] default test device: iPhone 17 (iOS 26.1).
airbuild-xcode: skipping simulator diagnostics collection (simctl diagnose waits 600 s on Xcode 27); pass -collect-test-diagnostics on-failure to collect them.
[airbuild-xcode] action=test; destination=id=<UDID> (default); CODE_SIGN_IDENTITY=default (-).
```

볼 수 있는 다른 줄:

| 줄 | 의미 |
| --- | --- |
| `[airbuild-xcode] archive starts over every run and keeps no cache; …` | 일반 빌드가 아카이브하고 있습니다. 증분 빌드를 하려면 `build:`에서는 `install`을 쓰고 `archive`는 `release:`에 두세요. `runbuild`가 결과 옆에 이를 경고로 다시 보여 줍니다. |
| `[airbuild-xcode] device build: dropped -destination …` | 기기용 빌드에서 시뮬레이터 대상이나 SDK가 제거되었습니다. |
| `[airbuild-xcode] device build: ad-hoc signed, no team or profile; CODE_SIGN_ENTITLEMENTS is preserved.` | 기기용 패키지 빌드입니다. |
| `[airbuild-xcode] Managed signing overrides via XCODE_XCCONFIG_FILE: …` | 서명된 빌드입니다. |
| `[airbuild-xcode] command-line ARCHS=… kept over the platform build settings.` | 내 설정이 빌더 설정보다 우선했습니다. |
| `[airbuild-xcode] version floor: raised …` / `nothing raised.` | 앱에서 시작한 빌드의 최소 버전 단계입니다. |

## 종료 코드와 오류

`airbuild-xcode`는 `xcodebuild`의 종료 코드로 종료합니다. 다음 경우에는 `xcodebuild`를 실행하기 전에 `64`로 멈춥니다.

| 메시지 | 해야 할 일 |
| --- | --- |
| `airbuild-xcode: start with install, archive, test or -showBuildSettings; use xcodebuild directly for other operations.` | 동작을 맨 앞에 두거나 `xcodebuild`를 호출하세요. |
| `airbuild-xcode: use one leading action; run other Xcode operations separately.` | `-list`, `-version`, `-show…`, `-exportArchive`, `-resolvePackageDependencies` 등을 빼고 `xcodebuild`로 실행하세요. (`-showBuildTimingSummary`는 허용됩니다.) |
| `airbuild-xcode: -configuration requires a value.`(또는 `-destination`) | 값을 지정하세요. |
| `airbuild-xcode: a signed or device build exports an archive; put airbuild-xcode archive in the release: recipe of airbuild.yaml …` | `airbuild-xcode archive`를 실행하는 `release:` 레시피를 추가하세요. |
| `airbuild-xcode: no available iOS simulator could be selected. Install an iOS simulator runtime and device in Xcode, or pass -destination explicitly.` | `-destination`을 넘기거나 시뮬레이터 런타임을 설치하세요. |
| `airbuild-xcode: AIRBUILD_SIGN must be 0 or 1. Start managed signing through AirBuild.` | `AIRBUILD_SIGN`을 직접 설정하지 말고 `runbuild --sign`을 쓰세요. |
| `airbuild-xcode: signing preparation is incomplete. Start signing through AirBuild again.` | `runbuild --sign`을 다시 실행하세요. |

## 예시

```bash
# build.script: the everyday, incremental build
airbuild-xcode install -workspace App.xcworkspace -scheme App \
  DSTROOT="$PWD/.airbuild/artifacts/install"
```

```bash
# release.script: the archive for --sign and --unsigned
rm -rf .airbuild/artifacts/App.xcarchive
airbuild-xcode archive -workspace App.xcworkspace -scheme App \
  -archivePath .airbuild/artifacts/App.xcarchive
```

```bash
# A test entry, with runtest's --additional-options
airbuild-xcode test -workspace App.xcworkspace -scheme App \
  -resultBundlePath .airbuild/artifacts/Tests.xcresult $additional_options
```
