# iOS 빌드용 Fastlane 설정 커스터마이즈

> Configure Fastlane settings for iOS builds to control build behavior.

**Build Automation**은 Xcode 프로젝트를 빌드하기 위해 [Fastlane](https://fastlane.tools/)을 사용합니다. 이 기술 자료에서는 [Gymfile](https://docs.fastlane.tools/actions/gym/#gymfile)이라는 Fastlane 파일 포맷을 사용하여 Fastlane의 동작을 수정하는 방법을 설명합니다. 모든 설정 옵션은 Fastlane 전용이므로 몇 가지 기본적인 툴세트에 익숙해지는 것을 권장합니다.

이 섹션에서는 현재 여러 프로필로 프로젝트를 빌드하도록 설정하는 방법에 대한 기본 예제를 사용합니다. 다음 예제에서는 `"com.unity3d.buildautomation.base"`의 애플리케이션 식별자와 `"com.unity3d.buildautomation.base.stickers"`의 앱 식별자로 스티커 확장 프로그램을 사용하여 앱을 빌드한다고 가정합니다.

## 필수 파일 추가##add-required-files

이 설정을 수행하려면 현재 저장소에 추가 파일 3개를 추가해야 합니다.

### 파일 #1: 커스텀 Fastfile/Gymfile의 경로와 Fastfile의 [레인](https://docs.fastlane.tools/advanced/lanes/#lanes)을 제어하는 JSON 옵션 파일을 실행해야 합니다##file-1-a-json-options-file-that-controls-the-paths-to-your-custom-fastfilegymfile-and-which-laneshttpsdocsfastlanetoolsadvancedlaneslanes-in-the-fastfile-should-be-run

이 파일은 저장소의 어느 위치에나 배치할 수 있지만 이 예제에서는 `Assets/ucb_xcode_fastlane.json`에 배치합니다. 다음 프로퍼티를 지원합니다(모두 선택 사항이며, 프로퍼티를 사용하지 않으면 전부 제거). fastfile - 저장소의 루트를 기준으로 하는 커스텀 Fastfile의 경로. gymfile - 저장소의 루트를 기준으로 하는 커스텀 Gymfile의 경로. 레인 - 위에서 참조한 Fastfile 내의 레인. pre\_build - 실제 Xcode 빌드 단계 전에 실행되는 레인. post\_build - 실제 Xcode 빌드 단계 후 실행되는 레인.

이 경로는 모두 프로젝트의 루트를 기준으로 합니다.

`"Assets/ucb_xcode_fastlane.json"` 예제:

```js
(JavaScript)

{
    "fastfile": "Assets/ucb/Fastfile",
    "gymfile": "Assets/ucb/Gymfile",
    "lanes": {
        "pre_build": "use_stickers_profile",
        "post_build": ""
    }
}
```

### 파일 #2: 프로비저닝 프로파일을 설치하고 Xcode 프로젝트의 프로비저닝 설정을 업데이트하는 커스텀 Fastfile입니다##file-2-a-custom-fastfile-to-install-the-provisioning-profile-and-update-the-provisioning-settings-in-the-xcode-project

이 파일은 저장소 어느 위치에나 배치할 수 있지만 위의 `ucb_xcode_fastlane.json`에 지정된 ‘fastfile’의 경로와 일치해야 합니다.

pre\_build/post\_build 레인을 설정한 경우 해당 레인이 실행될 때 다음을 포함하는 옵션 해시가 전달됩니다. project\_dir - 이 프로젝트가 빌드하는 저장소의 루트입니다. build\_target - 이 빌드에 대한 빌드 타겟 식별자입니다. output\_directory - Xcode 프로젝트가 빌드할 최종 출력 디렉토리입니다.

이 예제에서는 저장소의 ‘Assets/ucb/Stickers.mobileprovision’에 프로비저닝 프로파일을 설치하고, 해당 프로파일을 사용하도록 Xcode 프로젝트의 ‘Unity-iPhone-Stickers’ 타겟을 업데이트합니다.

`Assets/ucb/Fastfile` 예제:

```rb
(Ruby)

lane :use_stickers_profile do |options|
    profile_path = File.join(options[:project_dir], 'Assets/ucb/Stickers.mobileprovision')
    FastlaneCore::ProvisioningProfile.install(profile_path)
    update_project_provisioning(
        xcodeproj: 'Unity-iPhone.xcodeproj',
        target_filter: 'Unity-iPhone-Stickers',
        profile: profile_path
    )
end
```

### 파일 #3: 익스포트 옵션 커스터마이즈의 일부로, 프로비저닝 프로파일 매핑에 대한 애플리케이션 식별자를 정의하는 커스텀 Gymfile입니다##file-3-a-custom-gymfile-to-define-the-application-identifier-to-provisioning-profile-mapping-as-part-of-customizing-the-export-options

이 파일은 저장소의 어느 위치에나 배치할 수 있지만, 위의 ucb\_xcode\_fastlane.json에 있는 ‘gymfile’의 경로와 일치해야 합니다. 사용 가능한 옵션은 [fastlane docs](https://docs.fastlane.tools/actions/gym/)를 참고하십시오.

이 예제에서 ‘com.unity3d.buildautomation.base.stickers’ 애플리케이션 식별자는 `1e33640e-9a55-4357-a632-ca6c48a53a96`의 UUID(`Assets/ucb/Stickers.mobileprovision`의 UUID 프로비저닝 프로파일)에 매핑되어야 합니다.

`Assets/ucb/Gymfile` 예제:

```rb
(Ruby)

export_options(
    provisioningProfiles: {
        "com.unity3d.buildautomation.base.stickers" => "1e33640e-9a55-4357-a632-ca6c48a53a96"
    }
)
```

## 고급 설정 업데이트##update-advanced-settings

대시보드에서 빌드 타겟에 대한 고급 설정을 업데이트하면 됩니다.

1. [Unity Dashboard](https://cloud.unity.com/)로 이동합니다.
2. **DevOps** > **Build Automation** > **Configurations**를 선택합니다.
3. iOS 빌드 타겟으로 이동합니다.
4. **Edit**를 선택합니다.
5. Edit Advanced Options 탭으로 이동합니다.
6. **Platform specific settings (iOS)** 옵션에서 프로젝트의 루트를 기준으로 하는 경로인 커스텀 Fastlane 구성 경로를 설정합니다. 이 예제에서는 ‘Assets/ucb\_xcode\_fastlane.json’으로 설정되어 있습니다.


**‘iOS 빌드용 Fastlane 구성 커스터마이즈’:**
![‘iOS 빌드용 Fastlane 구성 커스터마이즈’](/api/media?file=/build-automation/media/images/build-automation/fastlane-config.png "UBA - Gymfile 설정 - Fastlane 구성")
