# App builds (managed cloud, outside the EU)

Build an iOS or Android app from source on a cloud builder, from inside a miniVM, and install it on a cloud device. Managed cloud only, off by default, run outside the EU.

With app builds, your agent builds an iOS or Android app from the source in its miniVM, on a cloud
builder, and installs it on one of the miniVM's [cloud devices](https://onshore.sh/docs/devices). It is the `device build`
command, inside the miniVM.

> **Note:** **Not offered to every organization yet.** App builds are off by default and are turned on per
> organization. They also need [cloud devices](https://onshore.sh/docs/devices#turn-them-on) turned on, and an owner's
> acceptance of the current consent text (see [Before you start](#before-you-start)).

> **Warning:** **App builds run outside the EU.** Builders run at the same third-party provider as cloud devices,
> established outside the EU and subject to non-EU law. Your source code and your build logs leave
> the EU and are stored by that provider. See [Your data](#your-data).

## What you can build

| Platform | Projects                                                                                                | Output                                                                            |
| -------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| iOS      | An Xcode workspace or project (at the root or in `ios/`), an XcodeGen `project.yml`, React Native, Expo | A simulator build, installed on an iOS simulator                                  |
| Android  | A Gradle project (at the root or in `android/`), React Native, Expo (with or without `android/`)        | A Gradle task's APK, `assembleDebug` by default, installed on an Android emulator |

## Before you start

- Your organization has [cloud devices turned on](https://onshore.sh/docs/devices#turn-them-on), on the managed cloud. App
  builds are not available on a self-hosted deployment or on miniVMs of a [Hybrid](https://onshore.sh/docs/guides/hybrid)
  pool.
- An owner has accepted the consent text of 30 November 2026 or later, which covers source code.
  An organization that turned cloud devices on under an earlier text keeps its devices, but its
  builds are refused (`devices_disabled`, detail `consent_outdated`) until an owner accepts the
  current text.
- Your balance holds enough credits (see [Billing](#billing)).

## Build and install

Inside the miniVM, add a device, then build from your app's folder:

```bash
device add ios_simulator --wait
device build ios
```

```bash
device add android_phone --wait
device build android
```

`device build` sends your source to the builder, waits for the builder to be ready, builds, then
installs and relaunches the app on the miniVM's single ready device of that platform. It ends with
one line, such as `✓ built Shop (Debug, iphonesimulator) in 12s · incremental · installed on dev_…`.
Then drive the app as on any [cloud device](https://onshore.sh/docs/devices).

- **Keep the device.** A first build takes minutes, and building does not keep the device from
  its idle release. Run `device keep --for 30m` before it. Once the builder is warm, a rebuild
  usually takes seconds.
- **Which device.** With two or more ready devices of the platform, pass `--install=<device-id>`.
  With no single ready device, the build still succeeds (exit code `0`) and its line ends with
  `not installed: no single ready … device`.

To build another folder, give its path:

```bash
device build android <path-to-app>
```

`<path-to-app>` is the folder of the app, relative to the current folder. Give it when
`device build` says `Nothing to build for iOS in …` or `Nothing to build for Android in …`; in a
monorepo, add `--expo-app-dir` for an Expo app.

One build runs at a time per platform and miniVM. Ctrl-C before the build starts cancels it; after
it started, Ctrl-C only stops following it and the build goes on.

### Options

| Option                                                                      | Effect                                                                                                                                               |
| --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--install=<device-id>`                                                     | Install on this device (`dev_…`) instead of the single ready one                                                                                     |
| `--no-install`                                                              | Build only                                                                                                                                           |
| `--clean`                                                                   | Build from scratch instead of incrementally                                                                                                          |
| `--include <glob>`                                                          | Also send paths that `.gitignore`, the default skips or the secret-like rule leave out (repeatable)                                                  |
| `--include-secrets`                                                         | Also send every secret-like file git does not ignore (see [What is sent](#what-is-sent))                                                             |
| `--detach`                                                                  | Return once the build started, printing its id                                                                                                       |
| `-o <file>`                                                                 | Also write the whole build log to this file, created readable by you only (`0600`)                                                                   |
| `--timeout <duration>`                                                      | Longest the build may run, from `1m` to `60m` (default `30m`)                                                                                        |
| `--replace`                                                                 | Cancel the build already running on this platform's builder and start this one                                                                       |
| `--scheme`, `--workspace`, `--project`, `--configuration`, `--expo-app-dir` | iOS: Xcode scheme, `.xcworkspace` or `.xcodeproj` (relative to the app folder), build configuration (default `Debug`), Expo app folder in a monorepo |
| `--task`, `--module`                                                        | Android: Gradle task (default `assembleDebug`) and module (default: the app module)                                                                  |
| `--json`                                                                    | Print one JSON value instead of text                                                                                                                 |

Run `device build ios --help` or `device build android --help` for every option with examples.

### What is sent

`device build` sends the app folder from the miniVM. It follows git's ignore rules
(every `.gitignore` from the top of the repository, `info/exclude` and your global excludes file),
and skips version control folders, dependencies and build outputs (`node_modules`, `Pods`,
`DerivedData`, `.gradle`, `.expo`, `build` and similar). `.git` and `local.properties` are never
sent. After the first build, it sends only what changed.

- Gitignored `.env*` and `*.xcconfig` files stay in the miniVM. The build names them; add
  `--include <glob>` to send one the build needs. A build that fails with "Unable to open base
  configuration reference file" usually lacks such a gitignored `.xcconfig`: send it with
  `--include <path>`.
- Secret-like files are **not sent**, even when they are not gitignored: `.env`, `.env.*` (but
  `.env.example`, `.env.sample` and `.env.template` are sent), `*.pem`, `*.key`, `*.p8`, `*.p12`,
  `*.pfx`, `*.mobileprovision`, `*.keystore` and `*.jks` (but `debug.keystore` is sent),
  `id_rsa*`, `id_ed25519*`, `id_ecdsa*`, `.netrc`, `.npmrc`, `.git-credentials`,
  `*secret*.xcconfig`, and the folders `.ssh`, `.aws` and `.gnupg`. The build prints
  `not sent (secret-like): …` with up to 5 names and a count of the rest, and `--json` lists up to
  50 of them in `excluded` (a folder with a trailing `/`).
- If the build needs one, send it explicitly: `--include .env` (an Expo app reading
  `EXPO_PUBLIC_*` from `.env`), `--include 'ios/*.p12'`, or `--include-secrets` for every one git does not ignore (a gitignored one still needs
  `--include`).
  Only send values fit for a shared test build.
- `google-services.json` and `GoogleService-Info.plist` are sent, with a note, unless gitignored.
- Building from `/`, your home folder, or a folder inside or holding `~/.ssh`, `~/.aws`,
  `~/.config/gcloud`, `~/.gnupg`, `/etc` or other system folders is refused (exit code `2`): pass
  the app's folder, for example `device build ios ./MyApp`.
- A symlink that points outside the folder refuses the build before anything is sent.
- A sync over 2 GiB is refused.

Do not send production secrets to a builder: they leave the EU with the rest of the source.

## Follow, list and cancel builds

```bash
device builds
device build-logs
device build-cancel
```

- `device builds` lists the miniVM's last 50 builds, newest first.
- `device build-logs [<build-id>]` follows a build's log to its end, or replays the log of a build
  that ended. `-o <file>` also writes it to a file.
- `device build-cancel [<build-id>]` cancels a build.

`<build-id>` is a build's id (`bld_…`), as `device build` or `device builds` printed it. Without
it, `build-logs` takes the newest build and `build-cancel` the running one.

## Compiler errors

When a build fails, `device build` exits with code `1` and prints the first compiler errors as
`file:line:col: message`, with paths relative to your app folder: the first 10, then how many
more. When no error could be read, it prints the last lines of the log instead. It reads Swift, clang, ld,
xcodebuild, Gradle, Kotlin, javac, AAPT, TypeScript, Babel and Metro errors. With `--json`, the
result is one object:

```json
{"build_id": "bld_…", "status": "failed", "duration_s": 14, "incremental": true,
 "installed_on": null, "errors": [{"file": "Sources/App.swift", "line": 12, "col": 5,
 "message": "cannot find 'x' in scope"}], "log_tail": "…"}
```

`errors` holds at most 50 distinct errors; `file`, `line` and `col` are `null` when the error
does not name them. `log_tail` holds the last lines of the log.

## React Native and Expo: reload JavaScript without rebuilding

Start Metro in the miniVM and tunnel its port to the device before the build, since the build
relaunches the app:

```bash
npx expo start --port 8081 > metro.log 2>&1 &
device tunnel 8081 > tunnel.log 2>&1 &
device build ios
```

`device tunnel 8081` makes the device's `localhost:8081` reach `127.0.0.1:8081` in the miniVM. It
runs until you press Ctrl-C, and reconnects on its own after a network drop.

A Debug build loads its JavaScript from the device's `localhost:8081`, which the tunnel serves:

- **iOS simulator, and an Expo app without a dev client on the Android emulator.** It connects to
  Metro once relaunched.
- **Android, Expo dev client.** Open the dev server in the app after the build:

  ```bash
  device open-url "<scheme>://expo-development-client/?url=http%3A%2F%2Flocalhost%3A8081"
  ```

  `<scheme>` is your app's URL scheme.
- **Android, React Native without Expo.** If the app does not reach Metro, open its dev menu,
  then Settings, and set Debug server host & port for device to `localhost:8081`.

If the app opened before Metro answered, it shows "No script URL provided": reload it once Metro
is up.

Then reload the app after a JavaScript change: no rebuild. Rebuild after a native change, such as
a native module, a config plugin, the Podfile or a Gradle file.

`device tunnel <port> [<device-id>]` takes any port from 1024 to 65535, the same on both sides;
the device id comes last. One tunnel runs per device. Data through the tunnel counts as device
activity; an idle tunnel does not keep the device from its idle release. A Debug app connected to
Metro keeps data flowing, so the device stays billed until you run `device remove`.

## Builders

The first build of a platform starts a builder for the miniVM. The next builds of that platform
reuse it and its build cache, so a rebuild after a small change compiles only what changed.

```bash
device builders
device builder-rm <builder-id>
```

`device builders` lists the miniVM's builders: platform, state, its
price per minute, whether it restored a build cache (warm) and when it is released if idle. `<builder-id>` is a builder's id (`bldr_…`), as
`device builders` printed it.

- **Idle release.** A builder is released 10 minutes after its last build. Every build step
  pushes that back, and `device keep` on a device also keeps the builder of the same platform as
  long. `device builder-rm` releases it at once; it is refused while a build runs, so run
  `device build-cancel` first.
- **Warm cache.** A released builder saves its build cache first. The next build starts a new
  builder from that cache (shown as warm), so it does not rebuild everything. While the cache is
  still being saved, `device build` prints `waiting for the previous builder to save…` and retries
  on its own.
- **Pause and resume.** When the miniVM pauses, its builders save their cache and are released,
  and a running build is cancelled. After the resume, the next build starts warm.
- **Shared within your organization.** When the app folder is in a git repository with a remote,
  the cache is kept per repository and branch, for every miniVM of your organization; a new branch
  starts from the default branch's cache. Without a remote, the cache is kept per miniVM.

## Limits

| Limit                     | Value                                          |
| ------------------------- | ---------------------------------------------- |
| Builders per miniVM       | 1 per platform                                 |
| Builds at once            | 1 per builder                                  |
| Builders per organization | 10                                             |
| Idle release              | 10 minutes after the last build                |
| Build duration            | `--timeout`, from 1 to 60 minutes (default 30) |
| Source per sync           | 2 GiB                                          |

To raise an organization limit, write to <support@onshore.sh>.

## Billing

- **Per started minute, from creation to release.** A builder is billed from the moment it is
  created, its start included, until it is released. A minute in which a build ran, even partly, is billed at the builder's
  building price; any other minute at its warm price. A started minute counts in full.
- **Failed builders are free.** A builder that never becomes ready costs nothing.
- **Price.** See [Pricing](https://onshore.sh/docs/account/pricing#app-builds). A builder keeps the price it started at.
- **From your credits.** Builder minutes are drawn from your credits like the rest of your usage.
  A build needs at least 10 minutes of the building price of each of your organization's
  builders, the new one included, in your balance.
- **At 0 credits.** A running build runs to its end; no other build starts, and the builder is
  released.

Release builders you no longer need with `device builder-rm`.

## Refusals

A refused build prints a sentence that says what to do. With `--json`, the error carries the
`reason`.

| HTTP | `reason`                 | `detail`                                  | What to do                                                                                                                                                                          |
| ---- | ------------------------ | ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 402  | `insufficient_credits`   |                                           | Add credits                                                                                                                                                                         |
| 403  | `devices_disabled`       | `consent_outdated`                        | An owner accepts the current consent text in the console                                                                                                                            |
| 403  | `devices_disabled`       | `not_enabled`, `payment_method`, `hybrid` | As for [cloud devices](https://onshore.sh/docs/devices#refusals)                                                                                                                    |
| 409  | `build_busy`             | the running build's id                    | Follow it with `device build-logs`, or build again with `--replace`. For `device builder-rm`: `device build-cancel`, then retry                                                     |
| 409  | `build_not_synced`       |                                           | Run the build again                                                                                                                                                                 |
| 409  | `builder_released`       |                                           | Run the build again: a new builder starts                                                                                                                                           |
| 429  | `builder_quota_exceeded` | `org_cap`                                 | Your organization holds its 10 builders: release an idle one with `device builder-rm`, or retry after `Retry-After`                                                                 |
| 429  | `builder_quota_exceeded` | `minivm`                                  | The miniVM's previous builder is still saving its cache: `device build` waits and retries for up to 15 minutes. If it gives up, retry once later; `device builder-rm` does not help |
| 503  | `builder_capacity`       |                                           | No builder is free right now: retry after `Retry-After`                                                                                                                             |
| 400  | `invalid_request`        | the refused field, such as `scheme`       | Fix the value of the option `device build` names                                                                                                                                    |

A build that started can also end without succeeding:

| `device build` prints                                                                                                                      | What to do                                                                            |
| ------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
| `was cancelled (insufficient_credits)`                                                                                                     | Add credits                                                                           |
| `was cancelled (the miniVM was paused)`, `was cancelled (its builder was released)`, `was lost`, `No builder was ready … after 15 minutes` | Run the build again                                                                   |
| `ran out of time`                                                                                                                          | Raise `--timeout` (at most `60m`), or run the build again: it continues incrementally |

## What is not supported

- Builds for a physical device: no signed device `.ipa`, no device provisioning.
- Uploads to the App Store or Google Play.
- A watch mode that rebuilds on every change: run `device build` again.
- Physical devices.
- Self-hosted deployments and Hybrid pools.

## Your data

- **Consent.** The consent text an owner accepts (version of 30 November 2026) reads: "Cloud
  devices and app builds run at a third-party provider subject to non-EU law: your app, its source
  code, its build logs, its screens and its screenshots are sent to and stored by that provider,
  outside onshore.sh's EU perimeter. Copies of your source code kept to speed up builds are deleted
  at most 30 days after your last build."
- **At the provider.** Your source code and build logs are stored at the provider, outside the EU.
  The copies of your source code kept as build cache are deleted at most 30 days after your last
  build, and when your organization is deleted. iOS build caches are encrypted at rest by the
  provider. Android build caches are also encrypted with a key per organization that we hold,
  deleted with the organization. The provider keeps build logs under its own terms; we do not set
  that period.
- **Shared within your organization.** The build cache is kept per repository and branch for the
  whole organization: a miniVM of any member can reuse a cache, and the source code in it, that
  another member's build left.
- **What onshore.sh keeps.** Your source code passes through onshore.sh on its way to the builder;
  we never write it to disk or logs. For each build we keep its id, state, times and the last
  16 KiB of its log: the log excerpt is deleted 30 days after the build ended, the rest after 90
  days. Builder minutes are billing records, kept like your other billing lines.
- **In your miniVM.** `device build` keeps a copy of the files it last sent under
  `~/.cache/device/sync/`, to send only changes next time. It is deleted when the builder is
  released, and with the miniVM.

See [Cloud devices](https://onshore.sh/docs/devices#your-data) and [Data handling](https://onshore.sh/docs/security/data-handling).

Markdown version: https://onshore.sh/docs/app-builds.md
