---
title: "Build with remote Xcode"
description: "Compile iOS, watchOS, tvOS, and visionOS apps on a cloud Mac from Linux, Windows, or macOS, and install the result on a remote simulator."
sidebar:
  label: "Build with Xcode"
  order: 2
---

`lim xcode build` syncs your project to an Xcode sandbox, a Mac in the cloud, runs `xcodebuild` there, and streams the logs back. Your laptop or CI runner does not need to be a Mac. A successful build installs on an attached simulator, uploads to Asset Storage, or becomes a signed IPA.

If your app builds with Bazel, use [Bazel on Limrun](/bazel/build-on-limrun) instead: Bazel keeps running on your side and there is no source sync.

The build loop has four steps:

1. **Provision** an Xcode sandbox.
2. **Sync** your source folder to it.
3. **Run `xcodebuild`** on the remote Mac while the logs stream back.
4. **Install or ship.** Successful builds install on an attached simulator, or you upload the artifact.

## Pick your interface

The CLI covers the whole build surface. The SDKs cover it as follows:

| Surface | CLI | TypeScript | Python | Go |
|---|---|---|---|---|
| Provision an Xcode sandbox | ✓ | ✓ | ✓ | via REST |
| Sync source and run `xcodebuild` | ✓ | ✓ | not in SDK | not in SDK |
| Run one-shot project commands | ✓ | ✓ | not in SDK | not in SDK |

Python provisions with `xcode_instances.create` (see [Provision the sandbox yourself](#provision-the-sandbox-yourself)). Go provisions over REST (`POST /v1/xcode_instances`) or with `lim xcode create`. Then drive the build with `lim xcode build`. The [SDK capability matrix](/reference/sdk#sdk-capability-matrix) lists every surface by language.

## Build your project

Run the build from the project directory:

```bash
lim xcode build .
```

The first run creates an Xcode sandbox, or reuses the one remembered for your workspace. It syncs the directory, runs `xcodebuild` remotely, and streams the logs. For workspaces or multi-scheme projects, name the scheme and the workspace or project:

```bash
lim xcode build . --scheme MyApp --workspace MyApp.xcworkspace
```

`lim xcode build` is the only build command you need. It syncs before every build, so do not run a separate sync step or local `xcodebuild`.

### Provision the sandbox yourself

`lim xcode build` creates a sandbox on demand. Create one explicitly when you want labels, a specific lifecycle, or the instance before the first build:

```bash CLI
lim xcode create --reuse-if-exists --label session=demo
```

```ts TypeScript
import Limrun from '@limrun/api';

const lim = new Limrun({ apiKey: process.env['LIM_API_KEY'] });

const xcodeInstance = await lim.xcodeInstances.create({
  wait: true,
  reuseIfExists: true,
  metadata: { labels: { session: 'demo' } },
});

const xcode = await lim.xcodeInstances.createClient({ instance: xcodeInstance });
```

```python Python
from limrun_api import Limrun

lim = Limrun()  # reads LIM_API_KEY

xcode_instance = lim.xcode_instances.create(
    wait=True,
    reuse_if_exists=True,
    metadata={"labels": {"session": "demo"}},
)

print(xcode_instance.metadata.id, xcode_instance.status.state)
```

The sandbox and any simulator you attach are separate instances with their own lifecycles; see [Concepts](/concepts#instances).

TypeScript only: `createClient` opens a client for the sandbox. The `xcode` handle it returns is what the sync and build examples on this page use. The Python SDK has no sync or build client, so build on a Python-created sandbox with `lim xcode build --id <sandbox-id>`.

If another process created the instance and you only have its URL and token, open the client from those:

```ts
const xcode = await lim.xcodeInstances.createClient({ apiUrl, token });
```

When you know you will test on a simulator right after the build, create both instances and attach them in one call with `lim ios create --xcode` or `lim xcode create --ios`. They stay separate instances; the flag saves the attach step described in [Install on a simulator](#install-on-a-simulator).

### Reuse builds across instances

A sandbox the CLI creates restores and later saves its build workspace under a snapshot key derived from Git `origin` and the project directory. Override the key with `--snapshot-key`, or create without a snapshot with `--no-snapshot` (with `lim ios create --xcode`, the flags are `--xcode-snapshot-key` and `--no-xcode-snapshot`, because `--snapshot-key` there names the simulator snapshot). Run `lim xcode delete --wait-snapshot` after building to publish it for the next instance. See [Disk snapshots](/ios/snapshots) for the full workflow, branch fallbacks, and SDK usage.

## Install on a simulator

Prefer attaching the simulator to your Xcode sandbox when iterating on an app. After the first transfer, rebuilds skip unchanged files and send binary patches when they are smaller than the changed files. Small rebuilds can be much faster than uploading the full app to Asset Storage and downloading it to the simulator each time.

Attach a simulator to the Xcode sandbox at any time. The attach installs the latest successful build immediately, and every later successful build installs and launches on it. `lim ios create --attach` creates a simulator and attaches it in one step; `lim xcode attach-simulator` attaches one that already exists:

```bash CLI
# Create a simulator and attach it (installs the latest successful build)
lim ios create --attach

# Or attach an existing simulator
lim xcode attach-simulator <instance-id>
```

```ts TypeScript
await xcode.attachSimulator(iosInstance);
// or with a raw URL and token:
await xcode.attachSimulator({ apiUrl: '...', token: '...' });
// or create a fresh simulator and attach it in one call:
const { simulator } = await xcode.attachNewSimulator();
```

Python and Go have no attach call; attach with an HTTP call instead: `POST {xcode status.apiUrl}/simulator` with the Xcode sandbox's `status.token` as the bearer token and the body `{"apiUrl": "<simulator status.apiUrl>", "token": "<simulator status.token>"}`.

If the automatic install fails, including when the simulator has been deleted, the build logs a warning and continues with any requested artifact upload. The install error does not fail the build. Attach a running simulator to install the latest successful build without rebuilding.

Attach a different simulator to test the same build on another device model. [Run a simulator](/ios/run-simulator) covers everything you can do with the running app.

To stop automatic installation, detach the simulator from the sandbox:

```bash
lim xcode detach-simulator --id <xcode-instance-id>
```

In TypeScript, call `await xcode.detachSimulator()`. With HTTP, send `DELETE {xcode status.apiUrl}/simulator` using the sandbox's bearer token. The response reports `attached: false`. Repeated requests succeed. Both instances, installed apps, and retained build artifacts remain available. Detach waits for an active app transfer or test run to finish and stops the sandbox's simulator keepalive.

### Move off the embedded Xcode sandbox

Older clients created the Xcode sandbox inside the iOS instance with `spec.sandbox.xcode.enabled` and read its URL from `status.sandbox.xcode.url`. The API no longer supports this: an iOS create that sets `spec.sandbox.xcode.enabled` fails, and responses no longer carry `status.sandbox`. The TypeScript SDK (from 0.54.0) and the `lim` CLI (from 0.35.0) no longer offer it.

You see one of these:

- API: `400` with `The embedded Xcode sandbox (spec.sandbox.xcode) was removed` on an iOS create from an older SDK, an older `lim`, or your own HTTP client. If `lim` sent the request, upgrade it. Otherwise change the code as shown below.
- TypeScript: `'sandbox' does not exist in type 'Spec'` on `iosInstances.create`, or `Property 'sandbox' does not exist on type 'Status'` where the code reads `status.sandbox.xcode.url`.
- CLI: `Expected an Xcode instance (sandbox_...), got ios_...` when an `ios_` ID is passed to a `lim xcode` command. A paired target the previous CLI remembered is ignored, so the next `lim xcode build` creates a new Xcode sandbox.

Create the Xcode sandbox on its own and attach the simulator to it:

```bash CLI
lim ios create --xcode                                       # new simulator and Xcode sandbox, attached
lim xcode create --attach --simulator-id <ios-instance-id>   # new Xcode sandbox for an existing simulator
```

```ts TypeScript
const xcodeInstance = await lim.xcodeInstances.create({ wait: true });
const xcode = await lim.xcodeInstances.createClient({ instance: xcodeInstance });
const { simulator } = await xcode.attachNewSimulator(); // or xcode.attachSimulator(existingIosInstance)
```

Pass the Xcode sandbox's ID, which starts with `xcode_` or `sandbox_`, to `lim xcode` commands and the simulator's `ios_` ID to `lim ios` commands. The two instances have separate lifecycles: delete each one, or let each time out on its own.

## Sync your source

Every `lim xcode build` syncs first. The first sync uploads everything; later syncs send only what changed. For a continuous sync without building, for example while a tool watches the remote workspace, use watch mode:

```bash CLI
lim xcode sync . --watch
```

```ts TypeScript
await xcode.sync('./my-app', {
  watch: true,             // re-sync on file changes
  install: true,           // install after each sync (attached simulator only)
  additionalFiles: [
    { localPath: '/home/dev/.netrc', remotePath: '~/.netrc' },
  ],
});
```

TypeScript only: `sync` keeps watching the folder by default (`watch` defaults to `true`) and installs after each sync (`install` also defaults to `true`). Pass `watch: false` for a one-shot sync.

### What gets synced

The sync always skips `.git`, `.DS_Store`, and the basis cache directory. It also skips these paths at the project root (nested copies are left to your nested `.gitignore` files):

- Build outputs: `build/`, `.build/`, `DerivedData/`, `Index.noindex/`, `ModuleCache.noindex/`, `.index-build/`.
- Dependency caches: `.swiftpm/`, `Pods/`, `Carthage/Build/`.

Anything under `xcuserdata/` or ending in `.dSYM/` is skipped at any depth.

Paths matched by your `.gitignore` files are skipped too, root and nested alike, with git's usual precedence. `.xcconfig` and `.env` files are synced even when `.gitignore` matches them, because the remote build needs them; exclude them explicitly with `--ignore` if you must. The force-include cannot reach a file whose parent directory is ignored, because the sync prunes that directory; use `--include` with a pattern that also matches the directory. If a file is both tracked by git and ignored, the sync warns you so you can fix the mismatch.

Symlinks sync as symlinks when their target is a relative path inside the synced folder, so setups that link shared sources into an app directory build the same remotely as locally. Symlinks with absolute targets are skipped with a warning. Relative links that escape the synced folder fail the sync; pass `--ignore` to skip them instead.

Dependency caches do not need to ship. The sandbox detects `Podfile`, `Package.swift`, or `Cartfile` and resolves dependencies on its side before the build. Keep them in your local `.gitignore` as usual.

### Exclude or force-include paths

To exclude something the sync does not already skip, pass a regular expression with `--ignore`. Repeat the flag for several patterns. `--include` works the other way: it force-syncs paths that `.gitignore`, a built-in rule, or `--ignore` would exclude. When a path matches both flags, `--include` wins. Use it when a local codegen step produces gitignored files the build needs:

```bash CLI
# Skip secrets and local-only config
lim xcode build . --ignore '^Secrets/' --ignore '\.local\.json$'

# A generated local Swift package the build depends on
lim xcode build . --include '^ios/GeneratedKit/'

# Prebuilt Carthage frameworks you would rather ship than rebuild
lim xcode build . --include '^Carthage/Build/'
```

```ts TypeScript
await xcode.sync('./my-app', {
  watch: false,
  ignore: (relPath) =>
    relPath.startsWith('Secrets/') || relPath.endsWith('.local.json'),
  include: (relPath) => relPath.startsWith('ios/GeneratedKit/'),
});
```

Both flags take regular expressions, not gitignore syntax; TypeScript takes predicates instead of patterns. An excluded parent directory prunes its whole subtree, so to reach files inside it the pattern must also match the directory path itself, as the `--include` examples do (`^ios/`, not `GeneratedKit/`). The basis cache is never included.

### Tools that need a Git repository

Some project tools refuse to run outside a Git repository. The sync excludes `.git`, so pass `--git-init` to create a repository in the synced workspace before project generation, dependency resolution, and `xcodebuild`:

```bash
lim xcode build . --git-init
```

### Add files from outside the repository

When the build needs files that are not in your repository, such as a `.netrc` for private packages, a CI-only `Config.swift`, or a secrets file, sync them alongside the source. Each entry maps a local path to a remote path:

```bash CLI
# --additional-file local=remote; repeat the flag for each file
lim xcode build . \
  --additional-file "$HOME/.npmrc=~/.npmrc" \
  --additional-file "$HOME/.netrc=~/.netrc"
```

```ts TypeScript
await xcode.sync('./my-app', {
  watch: false,
  additionalFiles: [
    { localPath: '/home/dev/.netrc', remotePath: '~/.netrc' },
    { localPath: './ci/Config.swift', remotePath: 'Config.swift' },
  ],
});
```

Remote paths that start with `~/` expand to the sandbox's managed build home. Other remote paths are relative to the workspace. Use `.npmrc` as the destination for workspace-level registry configuration. The same flag works with `lim xcode sync`; repeat it on each build that needs these files.

For private-package 401s, check that the remote build has the registry configuration and credentials it needs. If `.npmrc` references `${NPM_TOKEN}`, pass `--env NPM_TOKEN="$NPM_TOKEN"` too. Keep credential contents out of logs and commits. Sync preserves file permissions, so set restrictive local permissions such as `chmod 600` before uploading.

### Keep the delta cache on CI

The basis cache is the local copy of the last sync that lets later syncs send only changes. It defaults to your OS temp directory, which CI runners wipe between jobs. Pin it to a persistent path with `--basis-cache-dir` (`basisCacheDir` in the SDK), for example `/var/cache/lim`.

## Generated Xcode projects

If [XcodeGen](https://github.com/yonaskolb/XcodeGen) generates your `.xcodeproj` and the project is gitignored, which is the recommended XcodeGen setup, there is nothing to configure. The sandbox generates the project from `project.yml` before each build:

```bash
lim xcode build .
```

The spec can sit at the repository root or one directory down, like a monorepo's `ios/`. Both are found without flags. Try it on [sample-xcodegen-app](https://github.com/limrun-inc/sample-xcodegen-app).

If your spec has another name or location, pin it. The three flags mirror `xcodegen generate --spec`, `--project`, and `--project-root`, with paths relative to the synced folder root:

```bash
lim xcode build . --xcodegen-spec specs/app.yml --xcodegen-project ios
```

| Flag | What it does |
|---|---|
| `--xcodegen-spec <path>` | The spec file. Default: `project.yml` at the root. |
| `--xcodegen-project <dir>` | The directory the project is generated into. Default: the spec's directory. |
| `--xcodegen-project-root <dir>` | The directory the spec's relative paths resolve against. Default: the spec's directory. |

Passing any of these flags always regenerates the project, even when the sync supplied one. Without them:

- The sandbox generates only when you did not supply the project. A committed `.xcodeproj`, or one you force-sync, always wins and is never modified.
- The project regenerates on every build, so editing `project.yml` locally and rebuilding works. No stale project lingers on a reused sandbox.
- Codegen steps beyond `xcodegen generate`, such as a Makefile that produces a local Swift package or config-derived sources, still run on your side before the sync. If their output is gitignored, force-sync it with `--include`.
- The sandbox uses the selected XcodeGen tool. Select its compatibility line with `lim xcode use xcodegen@2`, or pin an exact release with a sandbox mise override; see [Xcode and tool versions](/ios/xcode-and-tools).
- If `project.yml` expands environment variables (`${VAR}`), the build log warns you: expansion uses the sandbox's environment, not yours.

## Run project commands

Use `lim xcode run` when the repository needs a macOS command, such as a Make target or a code generator. It syncs the current directory, then runs the command in the remote workspace:

```bash CLI
lim xcode run -- make api
```

```ts TypeScript
await xcode.sync('./my-app', { watch: false });

const command = xcode.run('make api', {
  cwd: '.',
  timeoutSeconds: 1800,
});

command.stdout.on('data', (line) => process.stdout.write(line));
command.stderr.on('data', (line) => process.stderr.write(line));
const { exitCode } = await command;
```

The CLI runs the command after `--`. In TypeScript, call `sync` before `run`, as the example does.

If a build or command returns HTTP `409` because sync is running, wait for sync to succeed and retry.

Use the remote `$TMPDIR` for temporary files instead of `/tmp` or `/private/tmp`.

The optional positional path sets the remote working directory, relative to the synced workspace. It defaults to `.`:

```bash
lim xcode run apps/api -- make generate
```

Add `--no-sync` when the sandbox already has the source state the command needs, and `--env KEY=VALUE` to set variables:

```bash
lim xcode run --no-sync -- make api
lim xcode run --env API_ENV=development -- npm run generate
```

Commands are one-shot. They stream stdout and stderr, return the remote exit code, and do not provide an interactive terminal. `--timeout` (`timeoutSeconds` in TypeScript) sets the server-side limit in seconds: 3600 by default, 21600 at most.

## Run xcodebuild from the SDK

The TypeScript SDK's `xcodebuild` starts the build on a synced sandbox and streams its output:

```ts
const build = xcode.xcodebuild({
  workspace: 'MyApp.xcworkspace',
  scheme: 'MyApp',
  sdk: 'iphonesimulator', // also iphoneos, watchsimulator, watchos, appletvos, xros
});

build.command.on('data', (line) => process.stdout.write(line));
build.stdout.on('data', (line) => process.stdout.write(line));
build.stderr.on('data', (line) => process.stderr.write(line));

const { exitCode, status } = await build;
// status: 'SUCCEEDED' | 'FAILED' | 'CANCELLED'
```

The call exposes three event-emitter channels while the build runs:

| Channel | Carries |
|---|---|
| `command` | The full command string the sandbox ran. One event, then it closes. |
| `stdout` | `xcodebuild` stdout as the build runs. |
| `stderr` | `xcodebuild` stderr. |

Awaiting the call resolves to a result with `exitCode` and `status` (`SUCCEEDED`, `FAILED`, or `CANCELLED`). Named uploads do not return a download URL; request one separately using a credential with `read` permission.

The `xcodebuild` settings match what you would pass locally:

| Field | Type | Meaning |
|---|---|---|
| `workspace` | string | Path to a `.xcworkspace`, such as `MyApp.xcworkspace`. |
| `project` | string | Path to a `.xcodeproj`. Use this or `workspace`, not both. |
| `scheme` | string | Required for multi-scheme apps. |
| `sdk` | string | `iphonesimulator` (default), `iphoneos`, `watchsimulator`, `watchos`, `appletvos`, or `xros`. tvOS and visionOS are device builds only. |

To return before the build finishes, or to receive the result on a webhook, see [Build logs and webhooks](/ci/build-logs-and-webhooks).

## Pass build settings

Pass custom build settings with a repeated `--build-setting KEY=VALUE`, or with `buildSettings` in TypeScript. Keys must be uppercase letters, digits, and underscores (`^[A-Z0-9_]+$`), and the server reserves a few managed keys. A build takes at most 32 settings, 4096 bytes per value, and 64 KiB in total. Your values apply after Limrun's managed settings and replace a managed value with the same key, so a project that needs to can override a default such as `ONLY_ACTIVE_ARCH`. `APP_CONFIG_*` values are treated as app configuration and redacted from build logs.

This build passes a staging API URL and a compilation condition:

```bash CLI
lim xcode build . --scheme MyApp \
  --build-setting APP_CONFIG_API_URL=https://staging.example.com \
  --build-setting SWIFT_ACTIVE_COMPILATION_CONDITIONS=STAGING
```

```ts TypeScript
xcode.xcodebuild(
  { scheme: 'MyApp' },
  {
    buildSettings: {
      APP_CONFIG_API_URL: 'https://staging.example.com',
      SWIFT_ACTIVE_COMPILATION_CONDITIONS: 'STAGING',
    },
  },
);
```

Build settings reach `xcodebuild` only. `--env KEY=VALUE` sets an environment variable for every remote build command instead: dependency installs, `expo prebuild`, `pod install`, and `xcodebuild`. Server-managed variables such as `PATH` cannot be overridden.

## Upload the build artifact

Upload the artifact to Asset Storage when you want to install it on other simulators, open it as a [PR preview](/ci/pr-previews), or keep it as a CI artifact:

```bash CLI
lim xcode build . --scheme MyApp --upload my-build.zip
```

```ts TypeScript
const upload = { target: 'name/my-build.zip' };
const instance = await lim.xcodeInstances.create({
  wait: true,
  spec: {
    role: {
      permissions: [
        'asset:name/my-build.zip:create',
        'asset:name/my-build.zip:upload',
        'asset:name/my-build.zip:update',
      ],
    },
  },
});
const xcode = await lim.xcodeInstances.createClient({ instance });
await xcode.sync('.');
await xcode.xcodebuild({ scheme: 'MyApp' }, { upload });
```

The CLI adds the upload grants when creating the instance. In SDK code, include your own permission strings alongside the upload grants in `spec.role.permissions`. An explicitly selected existing instance must already hold the grants; see [delegated permissions](/access/instance-roles).

Later creates can install it by name with `lim ios create --install-asset my-build.zip`. The uploaded asset expires 14 days after the last upload by default: each build upload pushes the expiry out again, so assets you keep rebuilding stay alive. Pass `--upload-ttl` with a Go duration (`ttl` in the SDK) such as `720h` to change the window; `1d` is not a valid Go duration. Assets uploaded with `lim asset push` never expire unless you give them a `--ttl`. [Asset Storage](/platform/asset-storage) covers the rest of the asset model.

To put the artifact in storage you already manage, pass a presigned S3, GCS, or R2 URL. The sandbox PUTs the artifact to it directly, so the bytes never travel through the machine that called `lim xcode build`. This also saves pulling a large build back through your CI runner:

```bash CLI
lim xcode build . --scheme MyApp --signed-upload-url '<presigned-url>'
```

```ts TypeScript
xcode.xcodebuild(
  { scheme: 'MyApp' },
  { upload: { signedUploadUrl: '<presigned-url>' } },
);
```

### When the product name differs from the scheme

For SDK calls below, create the instance with upload permissions for the chosen target as shown above.

The server finds the built `.app` on its own, including projects where the scheme and `PRODUCT_NAME` diverge, such as a scheme "MyApp Dev" that builds `MyApp-dev.app`. If an upload still fails with `built artifact not found`, name the bundle file, including the `.app` extension. The server then takes that name from the build products verbatim and skips discovery:

```bash CLI
lim xcode build . --scheme "MyApp Dev" --upload myapp-dev-build --artifact-name MyApp-dev.app
```

```ts TypeScript
xcode.xcodebuild(
  { scheme: 'MyApp Dev', artifactName: 'MyApp-dev.app' },
  { upload: { target: 'name/myapp-dev-build' } },
);
```

## Download a file from remote builder

Use `pull-file` to save a file from an existing builder to your machine:

```bash
lim xcode pull-file /tmp/app.zip ./app.zip --id <instance-id>
```

The remote path can be absolute or relative to the synced project root. Omit the destination to save under the same filename in your current directory.

Wait for the file to finish writing, archive directories first, and download before deleting the instance. Never use logs to transfer files.

## Active/Warm pricing

An Xcode sandbox costs **2 credits a minute while active** and **0.4 credits a minute while warm**. Active time covers builds, commands, source syncs, cache restores and saves, and other requests that change the workspace. Warm time is the rest of the sandbox's lifetime, while it waits for the next request. Simulators are billed separately.

Charges round up to whole credits per instance. Custom billing agreements may differ. If a sandbox leaves no usable activity data, its whole lifetime bills at 1 credit a minute.

To stop paying for warm time, delete the sandbox when you finish. Without `--inactivity-timeout`, an Xcode sandbox is deleted after 10 minutes of inactivity, unless your organization set a different default.

## Build flag reference

These are the `lim xcode build` flags. The flags every command shares (`--api-key`, `--json`, `--quiet`, `--[no-]create`, `--[no-]daemon`) are in the [CLI reference](/reference/cli). Run `lim xcode build --help` for the full text of each.

| Flag | What it does |
|---|---|
| `--scheme <name>` | Xcode scheme to build. |
| `--workspace <path>` | `.xcworkspace` to pass to `xcodebuild`. |
| `--project <path>` | `.xcodeproj` to pass to `xcodebuild`, as an alternative to `--workspace`. |
| `--configuration Debug\|Release` | Xcode build configuration. |
| `--sdk <sdk>` | `iphonesimulator`, `iphoneos`, `watchsimulator`, `watchos`, `appletvos`, or `xros`. tvOS and visionOS are device builds only. |
| `--xcode-version <major\|major.minor>` | Xcode for this one command. See [Xcode and tool versions](/ios/xcode-and-tools). |
| `--build-setting KEY=VALUE` | Pass an `xcodebuild` build setting, replacing a Limrun default with the same key. Repeatable. |
| `--env KEY=VALUE` | Set an environment variable for every remote build command. Repeatable. |
| `--log-processor xcbeautify\|none` | Format `xcodebuild` output with xcbeautify (default), or stream it unchanged. |
| `--xcodegen-spec`, `--xcodegen-project`, `--xcodegen-project-root` | Pin XcodeGen inputs. See [Generated Xcode projects](#generated-xcode-projects). |
| `--git-init` | Run `git init` in the synced workspace before the build. |
| `--ignore <regex>` | Skip matching paths during sync. Repeatable. |
| `--include <regex>` | Force-sync matching paths that would otherwise be excluded. Repeatable. |
| `--additional-file local=remote` | Sync an extra file, such as `~/.netrc`, on every build. Repeatable. |
| `--basis-cache-dir <dir>` | Directory for the local delta sync cache. |
| `--id <xcode-instance-id>` | Build on this sandbox instead of the most recent one for your workspace. |
| `--ios` | Build on a sandbox with an attached iOS simulator, creating and attaching one if needed. |
| `--inactivity-timeout <duration>` | Create a fresh sandbox for this build and delete it shortly after its last activity. Cannot be combined with `--id`. |
| `--upload <asset-name>` | Save the build artifact to Asset Storage under this name. |
| `--upload-ttl <duration>` | Expiry of the uploaded asset as a Go duration. Defaults to `336h` (14 days), counted from each upload. Requires `--upload`. |
| `--clean` | Delete Xcode's build folder (products and intermediates) before compiling, as Xcode's Clean Build Folder does. Use it to see every compiler warning on a warm sandbox, where unchanged files are not recompiled. |
| `--upload-option key=value` | App metadata to record on the uploaded asset (`displayName`, `bundleIdentifier`, `shortVersion`, `buildVersion`, `deeplink`). Values read from the built bundle take precedence. Repeatable. |
| `--artifact-name <App.app>` | Filename of the built `.app` to upload, skipping artifact discovery. |
| `--signed-upload-url <url>` | Upload the artifact to your own presigned URL. Defaults to `LIM_SIGNED_UPLOAD_URL`. |
| `--snapshot-key`, `--snapshot-restore-keys`, `--snapshot-paths`, `--no-snapshot` | Save and restore the sandbox workspace as a [disk snapshot](/ios/snapshots). A new sandbox defaults to a key derived from Git `origin`; `--no-snapshot` creates it without one. The older `--cache-*` names still work. |
| `--expo-app-dir <path>` | Path to the Expo app inside a monorepo or ambiguous React Native workspace. |
| `--expo-force-prebuild` | Run `expo prebuild` on the server even when the workspace already has an `ios/` directory. |
| `--expo-no-clean` | Pass `--no-clean` to Expo prebuild to update the existing `ios/` directory without deleting it first. Does not force prebuild to run. |
| `--dev-server-url <url>` | URL a Debug React Native or Expo build opens on the attached simulator after install. |
| `--certificate-p12`, `--certificate-password`, `--provisioning-profile` | Sign with your own certificate and profiles. See [Sign and distribute](/ios/sign-and-distribute). |
| `--signing-method`, `--team-id`, `--entitlements` | Use Apple cloud signing. Also requires `--asc-key-id`, `--asc-issuer-id`, and `--asc-key`. See [Sign and distribute](/ios/sign-and-distribute#cloud-signing). |
| `--upload-to-appstore`, `--asc-key-id`, `--asc-issuer-id`, `--asc-key` | Upload the signed IPA to App Store Connect. |
| `--asc-wait-timeout <seconds>` | Watch App Store Connect's processing verdict for up to this long (default 0, max 1800). |
| `--auto-build-number` | Set the build number to one more than the highest in App Store Connect, or 1 for a new app. Requires `--upload-to-appstore`. |
| `--detach` | Return once the build is accepted. See [Build logs and webhooks](/ci/build-logs-and-webhooks). |
| `--webhook-url`, `--webhook-header`, `--webhook-label` | POST the terminal build result to your HTTPS endpoint. See [Build logs and webhooks](/ci/build-logs-and-webhooks). |

## Troubleshooting

| Symptom or message | Cause | Fix |
|---|---|---|
| Upload fails with `built artifact not found` | The scheme name and the built product name differ and discovery missed the bundle. | Pass `--artifact-name` with the `.app` filename; see [When the product name differs from the scheme](#when-the-product-name-differs-from-the-scheme). |
| The sync fails on a symlink | A relative symlink points outside the synced folder. | Pass `--ignore` with a pattern for the link to skip it. |
| The sync warns that a file is tracked and ignored | The file is tracked by git but also matched by `.gitignore`. | Remove the file from git or from the ignore rule so the two agree. |
| A generated, gitignored file is missing on the sandbox | `.gitignore` excludes it, or its parent directory is pruned. | Force-sync it with `--include`, using a pattern that also matches the parent directory. |
| A project tool refuses to run outside a Git repository | The sync excludes `.git`. | Pass `--git-init`. |
| The build log warns about `${VAR}` in `project.yml` | XcodeGen expands variables with the sandbox's environment. | Do not rely on client-only variables in the spec; hard-code the value or generate the project locally and force-sync it. |
| `Expected an Xcode instance (sandbox_...), got ios_...` | An `ios_` simulator ID was passed to a `lim xcode` command, a leftover of the embedded Xcode sandbox. | Pass the Xcode sandbox's ID, which starts with `xcode_` or `sandbox_`; see [Move off the embedded Xcode sandbox](#move-off-the-embedded-xcode-sandbox). |
| `lim xcode logs` shows `RUNNING` | The build has not finished; a snapshot is not a result. | Follow it with `lim xcode logs --follow`; see [Build logs and webhooks](/ci/build-logs-and-webhooks). |

## Build cache logs

Open the Xcode instance's **Build logs** page in the console to see cache
restoration and publication in a separate **Cache activity** section. Your builds
stay in **Build activity**. Each cache entry shows its
outcome, duration, and readable progress messages, with copy and download controls. Publication
runs when the instance terminates; its duration counts the publication work,
not the time the instance spent waiting to terminate.

Completed cache logs remain available after the build finishes or the instance
terminates, subject to the same retention policy as build logs. Live cache status
and elapsed time appear above the history only while a cache operation is running.
Completed durations stay in **Cache activity**. Older operations without
persisted logs cannot be recovered.

The existing `GET /v1/xcode_instances/{id}/build_logs` endpoint includes cache
records with IDs starting with `cache-restore-` or `cache-publish-`. Their
`status` is the terminal cache phase in uppercase; `startedAt`, `finishedAt`,
and `buildDurationMs` describe the cache operation. The log upload itself is
excluded from the duration.

## Next steps

**[Xcode and tool versions](/ios/xcode-and-tools)**

Pick the Xcode release and the Node, Ruby, CocoaPods, and other tool versions a build uses.

**[Sign and distribute](/ios/sign-and-distribute)**

Produce signed device IPAs and upload them to App Store Connect and TestFlight.

**[Build logs and webhooks](/ci/build-logs-and-webhooks)**

Detach from a build, read its logs later, and receive the result on your endpoint.

**[GitHub Actions recipes](/ci/github-actions)**

Build and sign on every pull request from a Linux runner.
