# Build your app with a different Xcode version

> In a cloud Team, ask an Agent which Xcode versions it can build with, and have it build your app or run its tests with the one you pick.

Source: https://air.build/docs/build/build-with-a-different-xcode-version/

In a cloud Team, your app is built on a Mac builder in the cloud. The builders come in several environments, each with its own macOS and Xcode version. A build uses the default environment unless the Agent names another one. You can ask for another, for example to check that the app still builds with an older Xcode, or to try a newer one. Other scripts an Agent runs on a Mac builder, with [runmacos](https://air.build/docs/cli/runmacos/), can pick an environment the same way.

> [!NOTE]
> This is for cloud Teams. A local Team builds with the Xcode on its Mac: see [In a local Team](https://air.build/docs/build/build-with-a-different-xcode-version/#in-a-local-team). AirBuild has no setting for the Xcode version. You ask an Agent in the project's chat, and it uses `runbuild --list-environments` and `runbuild --environment` (see [runbuild](https://air.build/docs/cli/runbuild/)). On the builder, a build script runs Xcode with [airbuild-xcode](https://air.build/docs/cli/airbuild-xcode/).

## See which versions you can use

Ask in the project's chat, for example:

```text
Which Xcode versions can you build with?
```

1. The Agent runs `runbuild --list-environments`.
2. It tells you each environment it found: its name and its macOS and Xcode versions. The default comes first.

This page doesn't list the versions. The Agent reads the current list each time you ask.

## Build with the one you pick

Name the version you want, for example:

```text
Build the app with the oldest Xcode on that list and put it in Preview.
```

1. The Agent starts the build with `--environment` and the environment you picked. The help says a build on another environment may take longer to start.
2. When the build is done, it's like any other build. To open it in Preview, tap **Reinstall** (on iPhone, the app's icon). See [Run your app in Preview](https://air.build/docs/build/preview-your-app/#use-the-device).
3. If the build fails, the Agent tells you why, and you can ask it to fix the project for that Xcode.

The help puts it this way: "It picks what the app is built with, not where it runs." The Preview devices stay the same. To try the app on another device, pick it in Preview's device menu: see [Run your app in Preview](https://air.build/docs/build/preview-your-app/#choose-a-device).

## Use it for tests or a signed build

The same choice works when an Agent runs your app's tests, and for a signed build for TestFlight and the App Store. Name the version when you ask, for example:

```text
Run the tests with the newest Xcode you have.
```

For test runs, see [Have your Agents run your app's tests](https://air.build/docs/build/run-your-apps-tests/). For signed builds, see [Share a beta with TestFlight](https://air.build/docs/app-store/test-with-testflight/).

## Later builds

The choice is for one build. Nothing in the project remembers it: every build an Agent starts without naming an environment uses the default. When you want that version again, name it each time you ask for a build.

## In a local Team

A local Team builds with the Xcode on its Mac, so there's no list to choose from. To build with another version, change the Xcode on that Mac. AirBuild's **Set Up This Mac** shows the version in use, and its fix for a missing Xcode is to select one in **Xcode ▸ Settings ▸ Locations ▸ Command Line Tools**. See [Choose where your Agents run](https://air.build/docs/get-started/where-agents-run/#set-up-your-mac-for-a-local-team).

## Questions

**The Agent says builder environments belong to cloud Teams.**

The message is "Builder environments belong to cloud Teams; this Team builds with the Xcode on its owning Mac." Your Team is a local Team. See [In a local Team](https://air.build/docs/build/build-with-a-different-xcode-version/#in-a-local-team).

**The Agent says --environment takes an id from the list.**

The message is "--environment takes an id from `runbuild --list-environments`." The Agent didn't give the option an environment's ID. Ask it to list the environments again and build with the ID of one of them.

**Does this change the Xcode that Xcode Cloud uses?**

No. An Xcode Cloud workflow has its own **Xcode** and **macOS** versions under **Environment**. See [Build with Xcode Cloud](https://air.build/docs/app-store/build-with-xcode-cloud/#create-a-workflow).

**Can I build with an Xcode that isn't on the list?**

Not in a cloud Team: a build uses one of the listed environments. In a local Team, the Mac's own Xcode is used.
