# Build with Xcode Cloud

> Set up Xcode Cloud workflows, start a build by hand, follow each run's actions and issues, download what it made, and run it again.

Source: https://air.build/docs/app-store/build-with-xcode-cloud/

Xcode Cloud is Apple's build service. The **Xcode Cloud** tab shows your app's workflows (what Xcode Cloud builds, and when), its recent builds, and the product and repository it builds from. You can create and edit workflows, start a build, and open any build to see how it went. Everything is read from and written to App Store Connect.

The tab opens once your Apple Developer account is connected, an Apple team is switched on, the Project has had its first build and the app has an App Store Connect record. See [Share a beta with TestFlight](https://air.build/docs/app-store/test-with-testflight/#before-you-start) for what the tab shows until then.

## Open the Xcode Cloud tab

**iPhone**

Open the Project's chat and tap the tabs button (four squares) in the top-right corner. In the list under the tab cards, tap **Xcode Cloud**. It's in the **Build** group, next to **TestFlight**.

**Mac**

Open the Project's chat and choose **View › Go To › Xcode Cloud**. You can also open the inspector (**View › Show Inspector**, ⌥⌘I), click **New Tab** (**+**) and click **Xcode Cloud**.

The tab has three sections: **Workflows**, **Recent Builds** and **Product** (the product's **Name**, **Type** and **Repository**). Pull down to read them again.

## If Xcode Cloud isn't set up

If the app has never used Xcode Cloud, the tab says **Xcode Cloud Not Set Up**. AirBuild can't make the first Xcode Cloud product for an app. Create the first workflow in Xcode (**Product › Xcode Cloud › Create Workflow**) or on the App Store Connect website, then tap **Check Again**.

After that, you can make every other workflow from the tab.

## Create a workflow

A workflow says when Xcode Cloud builds, what it builds, and what it does with the result.

1. Under **Workflows**, tap **New Workflow…**.
2. Type a **Name**, and optionally a **Description**.
3. In **Project or Workspace**, type the path of the Xcode project or workspace, relative to the repository's root, for example `App.xcodeproj`.
4. Leave **Enabled** on so it can run. Turn on **Clean Build** if every build should start from a fresh checkout.
5. If the product has more than one repository, pick one under **Repository**.
6. Under **Environment**, pick the **Xcode** and **macOS** versions. A new workflow starts on the newest of each.
7. Choose how it starts (see **Start conditions** below).
8. Set up its actions (see **Actions** below).
9. Tap **Create**.

**Create** stays dimmed until the workflow has a name, a project or workspace, an Xcode and macOS version, at least one way to start ("A workflow needs at least one way to start.") and at least one action with a scheme ("A workflow needs at least one action.").

### Start conditions

Turn on each way the workflow should start. You can turn on several.

| Switch | Starts a build when | Fields |
| --- | --- | --- |
| **Branch Changes** | Someone pushes to a branch. | **Branches**; **Auto-Cancel Builds** |
| **Tag Changes** | A tag is pushed. | **Tags** |
| **Pull Request Changes** | A pull request is opened or updated. | **Source Branches**, **Target Branches** |
| **On a Schedule** | At set times. | **Branches**, **Frequency** (**Weekly**, **Daily** or **Hourly**), **Days** for weekly builds, **Time** and **Time Zone** for daily and weekly builds |

Under **Manual Start**, **Manually from Branches**, **Manually from Tags** and **Manually from Pull Requests** decide what you can pick when you start a build by hand.

In **Branches** and **Tags**, separate names with commas. "A trailing \* matches everything under a prefix — release/\* takes release/1.0 and release/2.0. Leave a field empty to match any."

### Actions

Each action is a section of its own. Tap **Add Action…** for another, and **Remove Action** to take one out.

| Field | What to set |
| --- | --- |
| **Action** | **Build**, **Analyze**, **Test** or **Archive**. |
| **Name** | What the run calls it. It starts as the action's kind. |
| **Scheme** | The Xcode scheme to use. Required. |
| **Platform** | iOS, macOS, tvOS, watchOS or visionOS. |
| **Destination** | For example **Any iOS Device** or **Any iOS Preview** (a simulator). The list follows the platform. |
| **Distribution** | Archive only: **None**, **Internal Testing Only**, or **TestFlight and App Store**. |
| **Required to Pass** | Whether the build fails when this action fails. |

A test action uses the test settings of its scheme.

## Edit, switch off or delete a workflow

Tap a workflow to open it, change what you need, and tap **Save**. A workflow that's switched off says **Disabled** on its row.

Touch and hold a workflow's row (on the Mac, right-click it) for its menu:

- **Start Build…** starts a build of this workflow.
- **Edit Workflow…** opens it.
- **Enabled** switches it on or off.
- **Delete Workflow…** deletes it.

An existing workflow also has **Locked for Editing**. "A locked workflow can't be changed until it is unlocked here or in Xcode."

To delete a workflow, choose **Delete Workflow…** from its menu, or open it and tap **Delete Workflow**: the trash at the bottom left on iPhone and iPad, the button at the bottom left on the Mac. The app asks **Delete _name_?**: "The workflow stops running and can't be brought back. Its earlier builds stay." Tap **Delete Workflow** to confirm.

## Start a build

1. Tap **Start Build…**. On iPhone it's at the start of the tab row at the bottom; on the Mac it's in the inspector's bar. You can also choose **Start Build…** from a workflow's menu.
2. Pick the **Workflow**. Only workflows that are switched on are listed.
3. Pick the **Branch or Tag**. It starts on the repository's default branch.
4. Turn on **Clean Build** to build from a fresh checkout.
5. Tap **Start Build**.

The new build appears at the top of **Recent Builds** and opens. **Start Build…** shows only when at least one workflow is switched on.

## Follow a build

Each row under **Recent Builds** shows the build number and workflow, for example "Build 128, Release", with the branch, when it started, its issue count and its status: **Pending** and **Running** while it's under way, then **Succeeded**, **Failed**, **Errored**, **Canceled** or **Skipped**. The list updates on its own while a build is running.

Tap a build to open it. On iPhone it opens as a page; on the Mac, as a sheet beside the chat. **Build _n_** shows:

- **Status**, **Workflow**, **Branch** or **Tag**, **Started** and **Duration**, and why it started or stopped, for example "Started by a push" or "Canceled by a newer build".
- **Commit**: the commit message, its ID, the **Author**, and **View Commit** to open it.
- **Actions**: each action with its kind, how long it took, its issues and its own status. An action marked "Not required to pass" doesn't fail the build.
- **Artifacts**: the files the build made, such as the archive, logs, the result bundle or the build products.
- The issues: each error, test failure or warning with its message and the file and line it points to.

### Download an artifact

Tap the download button on an artifact's row. On the Mac the file goes to your Downloads folder, and the row shows **Show in Finder** when it's done. On iPhone and iPad, choose where to save it.

### Run a build again

In a build, tap **Run Again** at the top and choose **Run Again** (same workflow, same branch or tag) or **Run Again from Clean** (from a fresh checkout). The new build appears at the top of **Recent Builds**.

## Ask your Agents

Your Agents can start builds, wait for the result and read the logs of a failed build with [asc](https://air.build/docs/cli/asc-automation/#xcode-cloud). Ask in the Project's chat, for example "Run the Release workflow on main and tell me if it fails".

## Questions

**New Workflow… is dimmed.**

The Xcode Cloud product has no repository yet. Connect one in Xcode or on the App Store Connect website, then pull down to read the tab again.

**I don't see Start Build….**

Every workflow is switched off, or there are none. Switch one on with **Enabled** in its menu, or create one.

**Create or Save stays dimmed.**

Check the fields: a **Name**, a **Project or Workspace**, an **Xcode** and **macOS** version, at least one start condition, and at least one action with a **Scheme**. A locked workflow can't be changed until you turn off **Locked for Editing**.

**The branch list shows an error.**

The branches and tags couldn't be read from the repository. Tap **Try Again**.

**A download failed.**

The row says "The file couldn’t be downloaded. Try again." Tap the download button again.

**The tab shows an error.**

Reading from App Store Connect failed, and the notice shows Apple's reason. Tap **Try Again**. An error after a change shows at the top of the tab.
