Skip to content
Documentation
Esc
↑↓navigate↵open⌘Jpreview
On this page

Build with Bazel (legacy)

The legacy `lim xcode rbe` path: build a Bazel iOS workspace on a dedicated Xcode sandbox, then run or share the app.

If your iOS app builds with Bazel (rules_apple, rules_swift), point it at Limrun’s remote build execution (RBE) backend instead of syncing sources. Bazel keeps running on your laptop or CI runner, and every Apple action (Swift compilation, asset catalogs, codesigning, bundling) runs on Limrun’s Macs. Linux, Windows, and macOS clients all work, and none of them needs Xcode.

The loop has three steps:

  1. Start the RBE endpoint with lim xcode rbe. It provisions an Xcode sandbox, starts the remote execution stack on it, and bridges it to a local port.
  2. Run the printed build command. Bazel sends actions through the tunnel, and results land in the remote cache.
  3. Run, upload, or preview the built app: install it on an attached simulator, or publish it as an asset.

Start the endpoint

You need the lim CLI and an API key; the Quickstart sets up both. From the root of your Bazel workspace (the directory with MODULE.bazel or WORKSPACE), start the endpoint:

lim xcode rbe

The command sets everything up and prints the exact build command for your workspace, for example:

bazelisk --digest_function=sha256 build --config=limrun //App

Run it. The tunnel keeps running in the background, so from here on you only build.

lim xcode rbe did three things:

  • Provisioned an Xcode sandbox, or reused your most recent one, and started the RBE stack on it.
  • Opened a tunnel so the endpoint is reachable at grpc://127.0.0.1:8980. Change the port with --port.
  • Generated a .limrun/ directory in your workspace with the --config=limrun Bazel configuration matched to the sandbox’s Xcode version, and wired a try-import into your .bazelrc.

To build with another installed Xcode, pass --xcode-version <major> for the newest GA release of that major, or --xcode-version <major.minor> to pin that exact version, which may be a beta. See Xcode and tool versions.

Do not hand-edit .limrun/; the next lim xcode rbe regenerates it. To add your own flags to the Limrun build path, put them in user.limrun.bazelrc at the workspace root. The generated config imports it last, so your build:limrun --... lines win and survive regeneration.

Run it on a simulator

lim xcode rbe is build-only until you attach a simulator. Attach one at startup with --ios, or at any point later:

lim xcode rbe --ios      # attach at startup; torn down on --stop
# or later:
lim ios create --attach  # attach to the running RBE instance

With a simulator attached, every successful --config=limrun build installs and relaunches the app on it. There is no separate install step, and attaching also installs the last successful build immediately.

Upload builds as assets

To publish builds to Asset Storage for PR previews, installs on other simulators, or CI artifacts, arm uploads when you start the tunnel:

lim xcode rbe --auto-upload preview/my-app --upload-ttl 24h

Every successful build then refreshes the preview/my-app asset, with no post-build step. Upload results are written to .limrun/rbe.log. To upload a single build after the fact instead:

lim xcode rbe upload preview/my-app --ttl 24h

TTLs are optional Go durations (24h, 30m). Each upload without one pushes the asset’s expiry to 14 days from that upload. Anyone in your organization can then open the build in a browser at https://console.limrun.com/preview?asset=preview/my-app&platform=ios.

To build on every pull request from CI, see the Bazel workflow in GitHub Actions recipes. For preview comments on pull requests, limrun-inc/ios-preview-action detects a Bazel workspace and does the build, upload, comment, and cleanup in one step; see PR previews.

Stop the endpoint

Stop the tunnel and the remote stack, then delete the sandbox when you are done with it:

lim xcode rbe --stop                  # stops the tunnel and the remote stack (~20s)
lim xcode delete <xcode-instance-id>  # delete the sandbox

The tunnel runs as a background process by default. Pass --no-daemon to keep it in the foreground, for example while debugging.

Limits and behavior

  • The built .ipa does not land on your machine. The generated config carries --remote_download_outputs=minimal. Bazel prints its usual Target //App:App up-to-date: .../App.ipa line, but the artifact stays in the sandbox’s cache, where auto-install and uploads read it. If you need the file locally, add --remote_download_outputs=toplevel to the build command.
  • Run lim xcode rbe from the workspace root, not a subdirectory. It writes .limrun/ there and fails otherwise.
  • Re-run after an Xcode change. The generated config pins the sandbox’s Xcode version. After a fleet upgrade or an --xcode-version switch, run lim xcode rbe --stop and then lim xcode rbe to refresh it.
  • Changing --auto-upload needs a restart. The CLI refuses to re-arm a running tunnel with a different upload configuration rather than silently ignoring it. Run --stop, then start again.

Next steps

Last updated on