limrun-xcode-bazel

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Bazel iOS builds on Limrun RBE

在Limrun RBE上进行Bazel iOS构建

Build Bazel Apple projects on Limrun's remote Mac workers — from any environment (Linux, Windows, macOS, VM, container), no local Xcode.
lim xcode rbe
brings up a remote RBE stack, tunnels it to a local port, and writes a
.limrun/
config so
bazelisk build --config=limrun
runs Apple actions remotely. Never fall back to local Xcode or build tools.
在Limrun的远程Mac工作节点上构建Bazel Apple项目——支持任意环境(Linux、Windows、macOS、虚拟机、容器),无需本地Xcode。
lim xcode rbe
会启动一个远程RBE栈,将其隧道连接到本地端口,并生成
.limrun/
配置文件,使
bazelisk build --config=limrun
能够远程执行Apple相关构建操作。无需回退到本地Xcode或构建工具。

Auth and CLI

认证与CLI

Install if needed:
npm install --global lim
. Auth is
lim login
or
LIM_API_KEY
(may be set outside the project — don't ask for it just because it's absent). The CLI is the source of truth: the commands in this skill are verified, but if a flag errors or you need one not shown here, check
lim xcode rbe --help
instead of guessing.
如需安装,请执行:
npm install --global lim
。认证方式为
lim login
或设置
LIM_API_KEY
(可在项目外部设置,无需因缺失而询问用户)。CLI是权威来源:本技能中的命令均已验证,但如果某个标记报错或需要此处未展示的标记,请查看
lim xcode rbe --help
,不要自行猜测。

Build

构建步骤

  1. From the Bazel workspace root (has
    MODULE.bazel
    /
    WORKSPACE
    ), run
    lim xcode rbe
    . It sets up the instance +
    .limrun/
    config and prints the exact build command. The tunnel runs in the background (prints a PID);
    --no-daemon
    keeps it foreground.
  2. Run the printed command, e.g.
    bazelisk --digest_function=sha256 build --config=limrun //App
    .
Don't hand-write
.limrun/
or the flags — the CLI generates them for the fleet's Xcode and your OS. Re-run
lim xcode rbe
(after
--stop
) to refresh after a fleet Xcode upgrade.
To add your own Bazel flags to the limrun path without editing the generated config, put them in
user.limrun.bazelrc
at the workspace root. The generated config try-imports it last, so your
build:limrun --…
lines win, and it survives
lim xcode rbe
regeneration (
.limrun/
does not).
  1. Bazel工作区根目录(包含
    MODULE.bazel
    /
    WORKSPACE
    )运行
    lim xcode rbe
    。它会设置实例和
    .limrun/
    配置文件,并打印出确切的构建命令。隧道将在后台运行(会打印PID);使用
    --no-daemon
    参数可使其在前台运行。
  2. 运行打印出的命令,例如:
    bazelisk --digest_function=sha256 build --config=limrun //App
请勿手动编写
.limrun/
配置或标记——CLI会根据集群的Xcode版本和你的操作系统自动生成。集群Xcode升级后,重新运行
lim xcode rbe
(先执行
--stop
)即可刷新配置。
若要在不编辑生成的配置的情况下,向limrun路径添加自定义Bazel标记,请在工作区根目录创建**
user.limrun.bazelrc
**文件。生成的配置会最后尝试导入该文件,因此你在其中添加的
build:limrun --…
行将生效,且该文件不会因
lim xcode rbe
重新生成而被覆盖(
.limrun/
则会被覆盖)。

Run on a simulator

在模拟器上运行

lim xcode rbe
is build-only; attach a simulator when the user wants to see or run the app. Check or attach (it installs the last build immediately, so no rebuild is needed):
bash
lim xcode get             # is a simulator already attached?
lim ios create --attach   # attach one
If the attach output includes a signed stream URL, share it with the user as a Markdown link, such as Live simulator.
With a simulator attached, every successful
--config=limrun
build automatically reinstalls and relaunches the app, no separate install step:
bash
bazelisk --digest_function=sha256 build --config=limrun //App
Notes:
  • Attach upfront if you already know you want a sim:
    lim xcode rbe --ios
    (attaches at startup, removed on
    --stop
    ).
  • Auto-install happens server-side from the build's events; there is no
    lim xcode rbe install
    subcommand or
    --target
    flag. To force a reinstall, rebuild (a cache-hit rebuild is seconds).
  • It fires when the successful invocation produced a single app, so in a multi-app workspace build one app target per invocation (
    //App
    , not
    //...
    ); a multi-app build succeeds but installs nothing.
To tap, type, read the element tree, screenshot, or record the running app, switch to the
limrun-ios-simulator
skill.
lim xcode rbe
仅用于构建;若用户希望查看或运行应用,请连接模拟器。检查或连接模拟器(连接后会立即安装最近一次构建的应用,无需重新构建):
bash
lim xcode get             # 是否已连接模拟器?
lim ios create --attach   # 连接一个模拟器
如果连接输出包含已签名的流URL,请将其以Markdown链接形式分享给用户,例如:实时模拟器
连接模拟器后,每次成功执行
--config=limrun
构建都会自动重新安装并重启应用,无需单独的安装步骤:
bash
bazelisk --digest_function=sha256 build --config=limrun //App
注意事项:
  • 若已知需要模拟器,请提前连接:执行
    lim xcode rbe --ios
    (启动时连接,执行
    --stop
    时断开)。
  • 自动安装在服务器端通过构建事件完成;没有
    lim xcode rbe install
    子命令或
    --target
    标记。若要强制重新安装,请重新构建(缓存命中的重建仅需数秒)。
  • 只有当成功的构建生成单个应用时,自动安装才会触发,因此在多应用工作区中,每次构建请指定一个应用目标(如
    //App
    ,而非
    //...
    );多应用构建会成功,但不会安装任何应用。
若要对运行中的应用进行点击、输入、读取元素树、截图或录制操作,请切换至**
limrun-ios-simulator
**技能。

Upload builds as assets

将构建产物上传为资产

To publish a build as a Limrun asset (preview links, installing on other simulators, CI artifacts), arm uploads at tunnel start or upload one build after the fact:
bash
lim xcode rbe --auto-upload preview/my-app --upload-ttl 24h  # every successful build refreshes the asset
lim xcode rbe upload preview/my-app --ttl 24h                # one-shot: the newest successful build
  • --auto-upload
    holds for the tunnel's lifetime: each successful
    --config=limrun
    build re-uploads the app under that asset name, no post-build step. Upload results land in
    .limrun/rbe.log
    .
  • rbe upload
    runs from the workspace root and needs a background tunnel plus at least one successful build; it errors otherwise.
  • TTLs are Go durations (
    24h
    ,
    30m
    ;
    1d
    is invalid) and optional.
  • To change the
    --auto-upload
    config of a running tunnel,
    --stop
    and re-run; the CLI refuses a mismatched re-arm instead of silently ignoring it.
  • Preview an uploaded app in a browser at
    https://console.limrun.com/preview?asset=<name>&platform=ios
    .
若要将构建产物发布为Limrun资产(预览链接、在其他模拟器上安装、CI工件),可在隧道启动时设置自动上传,或在构建完成后上传:
bash
lim xcode rbe --auto-upload preview/my-app --upload-ttl 24h  # 每次成功构建都会刷新该资产
lim xcode rbe upload preview/my-app --ttl 24h                # 单次上传:最新的成功构建产物
  • --auto-upload
    在隧道运行期间有效:每次成功执行
    --config=limrun
    构建都会将应用重新上传至指定资产名称下,无需构建后步骤。上传结果会保存到
    .limrun/rbe.log
    中。
  • rbe upload
    需从工作区根目录运行,且需要后台隧道和至少一次成功构建;否则会报错。
  • TTL为Go语言格式的时长(如
    24h
    30m
    1d
    无效),为可选参数。
  • 若要更改运行中隧道的
    --auto-upload
    配置,请先执行
    --stop
    再重新运行;CLI会拒绝不匹配的重新配置,而非静默忽略。
  • 可在浏览器中通过以下链接预览已上传的应用:
    https://console.limrun.com/preview?asset=<name>&platform=ios

Teardown

清理操作

Stop with
lim xcode rbe --stop
(~20s to tear the remote stack down) and delete the instance with
lim xcode delete <id>
执行**
lim xcode rbe --stop
停止服务(约20秒拆除远程栈),并执行
lim xcode delete <id>
**删除实例。

Gotchas

常见问题

  • Always pass
    --digest_function=sha256
    before
    build
    (use the command the CLI prints verbatim). The Limrun cache is SHA256-only; Bazel 9 defaults to BLAKE3. It's a startup flag, so it can't live in
    --config=limrun
    . Symptoms: build →
    Cannot use hash function BLAKE3 with remote cache
    ; install →
    non-SHA256 digest … rebuild with --digest_function=sha256
    .
  • Run
    lim xcode rbe
    from the workspace root
    , not a subdirectory — it writes
    .limrun/
    there and fails fast otherwise.
  • A green build doesn't prove remote execution — cache hits (
    action cache hit
    /
    remote cache hit
    ) make builds pass even with the tunnel gone. To force and verify real remote execution, see
    references/verify-remote.md
    .
  • The printed
    .ipa
    path won't exist on your machine
    — the build command carries
    --remote_download_outputs=minimal
    , which keeps the artifact in the instance's cache and downloads nothing. Bazel still prints its usual
    Target //App:App up-to-date: …/App.ipa
    line, but that file is not on disk. This is expected, not a failed build. With a simulator attached, the build auto-installs from the artifact's cache digest (read from the build event log, not the local file). Only if you genuinely need the
    .ipa
    locally, drop
    --remote_download_outputs=minimal
    from the build command and Bazel downloads the top-level output; auto-install keeps working either way.
  • A fresh instance can fail the first build with
    Lost inputs no longer available remotely
    (e.g.
    … Assets.car
    ). It's a transient cache eviction between instances, not a code error; Bazel prints
    Found transient remote cache error, retrying the build...
    and the retry succeeds. To avoid hitting it mid-demo, pre-warm with a full build right after
    lim xcode rbe
    .
  • You don't have permission to save … in "CoreSimulator"
    (actool/ibtool) is a fleet-side device gap, not your config. Retry; if it persists, report it to Limrun.
  • The project's own Bazel settings can fight RBE (Xcode pinned via a Starlark transition, custom
    remote_default_exec_properties
    , sandbox-hostile genrules). These are per-project, not Limrun bugs — walk
    references/project-compatibility.md
    before concluding RBE is broken.
  • 务必在
    build
    前传递
    --digest_function=sha256
    参数
    (使用CLI打印的完整命令)。Limrun缓存仅支持SHA256;Bazel 9默认使用BLAKE3。这是一个启动参数,因此无法在
    --config=limrun
    中设置。症状:构建时提示
    Cannot use hash function BLAKE3 with remote cache
    ;安装时提示
    non-SHA256 digest … rebuild with --digest_function=sha256
  • 请从工作区根目录运行
    lim xcode rbe
    ,不要从子目录运行——它会在根目录写入
    .limrun/
    ,否则会立即失败。
  • 构建成功并不代表已执行远程构建——缓存命中(
    action cache hit
    /
    remote cache hit
    )会使构建即使在隧道断开的情况下也能通过。若要强制并验证真正的远程执行,请查看
    references/verify-remote.md
  • 打印的
    .ipa
    路径在你的机器上不存在
    ——构建命令包含
    --remote_download_outputs=minimal
    ,该参数会将工件保留在实例缓存中,不会下载到本地。Bazel仍会打印常规的
    Target //App:App up-to-date: …/App.ipa
    行,但该文件并未存储在本地磁盘上。这是预期行为,并非构建失败。连接模拟器后,构建会通过工件的缓存摘要(从构建事件日志读取,而非本地文件)自动安装应用。只有当确实需要本地
    .ipa
    文件时,才从构建命令中移除
    --remote_download_outputs=minimal
    参数,Bazel会下载顶级输出文件;无论是否移除该参数,自动安装功能均正常工作。
  • 新实例首次构建可能会因
    Lost inputs no longer available remotely
    失败
    (例如
    … Assets.car
    )。这是实例间的临时缓存回收问题,并非代码错误;Bazel会打印
    Found transient remote cache error, retrying the build...
    ,重试后即可成功。若要避免在演示中遇到此问题,请在
    lim xcode rbe
    执行完成后立即进行一次完整构建以预热缓存。
  • You don't have permission to save … in "CoreSimulator"
    (actool/ibtool报错)是集群端的设备间隙问题,与你的配置无关。请重试;若问题持续,请向Limrun报告。
  • 项目自身的Bazel设置可能与RBE冲突(通过Starlark过渡固定Xcode、自定义
    remote_default_exec_properties
    、不兼容沙箱的genrules)。这些是项目特有的问题,并非Limrun的bug——在判定RBE故障前,请先查看
    references/project-compatibility.md
    。",