# simulator_install_app

> 这个 MCP 工具把项目最新的模拟器构建版本，或通过 HTTPS 下载的 App，安装到团队的模拟器上。

Source: https://air.build/cn/docs/mcp-tools/simulator_install_app/

`simulator_install_app` 通过以下两种方式之一，把 App 安装到团队正在运行的模拟器上：

- **从项目安装**（`projectId`）：安装项目最新的模拟器构建版本，也就是智能体最近为它构建的 App，并启动它。有些项目安装后会启动另一个 App（承载扩展的 App），或不启动任何 App。如果还没有构建版本，请先在项目的频道中让智能体构建（[send_message](https://air.build/cn/docs/mcp-tools/send_message/)）。
- **从下载安装**（`url`）：安装 `.ipa`，或包含 `.app` 的 `.tar` / `.tar.gz`（用 `bundlePath` 指定 `.app`）。链接必须是 HTTPS 且不能重定向，并且你要在 `sizeBytes` 中给出它的确切大小。以这种方式安装的 App 不会被启动：请用 [simulator_launch_app](https://air.build/cn/docs/mcp-tools/simulator_launch_app/) 打开它。

调用会等到安装完成，并向请求进度的客户端报告进度。安装已经存在的 App 会替换它。它不会删除设备上的其他任何内容。

| 只读 | 破坏性 | 幂等 |
| --- | --- | --- |
| 否 | 否 | 否 |

## 输入

`projectId` 和 `url` 必须恰好提供一个。

| 输入 | 类型 | 必填 | 默认值 | 作用 |
| --- | --- | --- | --- | --- |
| `teamId` | 字符串（UUID） | 是 | — | 团队，来自 [list_teams](https://air.build/cn/docs/mcp-tools/list_teams/) |
| `simulator` | string | 否 | 团队的默认设备 | 哪种设备，使用 [list_simulators](https://air.build/cn/docs/mcp-tools/list_simulators/#result) 中的 `id` |
| `projectId` | 字符串（UUID） | 两者之一 | — | 项目，来自 [list_projects](https://air.build/cn/docs/mcp-tools/list_projects/)：安装它最新的模拟器构建版本 |
| `url` | string | 两者之一 | — | 指向 `.ipa`、`.tar` 或 `.tar.gz` 的 `https://` 链接。由链接末尾的文件名决定是哪一种 |
| `sizeBytes` | 整数，至少为 1 | 与 `url` 一起使用 | — | 下载内容的确切字节数；大小不符会导致安装失败 |
| `bundlePath` | string | `url` 为 `.tar` 或 `.tar.gz` 时 | — | `.app`（或 `.xcarchive`）在归档中的路径，例如 `Build/Notes.app` |
| `launch` | boolean | 否 | `true` | 为 `false` 时，安装项目的构建版本但不启动。与 `url` 一起使用时没有作用 |

## 结果

| 字段 | 说明 |
| --- | --- |
| `installed` | `true` |
| `bundleId` | 模拟器报告的已安装 App 的 bundle ID；对于项目，在模拟器没有给出时为它启动的 App；否则为 `null` |
| `launched` | 安装后是否启动了 App |

```json
{ "installed": true, "bundleId": "com.example.notes", "launched": true }
```

## 错误

| 消息 | 何时出现 | 怎么办 |
| --- | --- | --- |
| Give exactly one of projectId or url. | 两者都提供了，或都没提供 | 发送其中一个 |
| url must be an HTTPS link. | `url` 不以 `https://` 开头 | 使用 HTTPS 链接 |
| sizeBytes is required with url: the download's exact size. | 有 `url` 但没有 `sizeBytes` | 添加以字节为单位的大小 |
| This Project's latest build can no longer be downloaded. Ask an Agent to build it again. | 最新的构建版本已过期 | 请智能体重新构建项目 |
| AirBuild answered 404. Try again in a moment. | 项目还没有模拟器构建版本 | 请智能体构建项目，然后重试 |
| bundlePath is required for archive downloads | `url` 为 `.tar` 或 `.tar.gz`，但没有 `bundlePath` | 添加 `bundlePath` |
| bundlePath must point at an .app or .xcarchive bundle inside the archive | `bundlePath` 不以 `.app` 或 `.xcarchive` 结尾 | 让它指向 `.app` |
| uploaded app must end in .app, .ipa, .apk, or .xcarchive | 链接的文件名不是 `.ipa` 或归档文件 | 链接到 `.ipa` 或 `.tar` / `.tar.gz` |
| The install failed: _reason_. | 下载或安装失败，例如 `sizeBytes` 有误时的 `downloaded 10 bytes, expected 12` | 按原因所述修正，然后重试 |
| The install did not finish: try again. | 安装没有及时完成 | 再次调用 |

另外还有每个模拟器工具都可能返回的错误：见 [start_simulator](https://air.build/cn/docs/mcp-tools/start_simulator/#device-errors)。

## 示例

```json
{"name": "simulator_install_app", "arguments": {"teamId": "00000000-0000-0000-0000-000000000000", "projectId": "00000000-0000-0000-0000-000000000000"}}
```
