# simulator_install_app

> 這個 MCP 工具會把專案最新的模擬器建置版本，或透過 HTTPS 下載的 App，安裝到團隊的模擬器上。

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

`simulator_install_app` 會以下列兩種方式之一，把 App 安裝到團隊正在執行的模擬器上：

- **從專案安裝**（`projectId`）：安裝專案最新的模擬器建置版本，也就是 Agent 最近為它建置的 App，並啟動它。有些專案安裝後會啟動另一個 App（承載延伸功能的 App），或不啟動任何 App。如果還沒有建置版本，請先在專案的頻道中請 Agent 建置（[send_message](https://air.build/tw/docs/mcp-tools/send_message/)）。
- **從下載安裝**（`url`）：安裝 `.ipa`，或包含 `.app` 的 `.tar` / `.tar.gz`（用 `bundlePath` 指定 `.app`）。連結必須是 HTTPS 且不能重新導向，而且你要在 `sizeBytes` 中提供它的確切大小。以這種方式安裝的 App 不會被啟動：請用 [simulator_launch_app](https://air.build/tw/docs/mcp-tools/simulator_launch_app/) 開啟它。

呼叫會等到安裝完成，並向要求進度的用戶端回報進度。安裝已經存在的 App 會取代它。它不會刪除裝置上的其他任何內容。

| 唯讀 | 破壞性 | 冪等 |
| --- | --- | --- |
| 否 | 否 | 否 |

## 輸入

`projectId` 和 `url` 必須剛好提供一個。

| 輸入 | 類型 | 必填 | 預設值 | 作用 |
| --- | --- | --- | --- | --- |
| `teamId` | 字串（UUID） | 是 | — | 團隊，來自 [list_teams](https://air.build/tw/docs/mcp-tools/list_teams/) |
| `simulator` | string | 否 | 團隊的預設裝置 | 哪種裝置，使用 [list_simulators](https://air.build/tw/docs/mcp-tools/list_simulators/#result) 中的 `id` |
| `projectId` | 字串（UUID） | 兩者之一 | — | 專案，來自 [list_projects](https://air.build/tw/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. | 最新的建置版本已過期 | 請 Agent 重新建置專案 |
| AirBuild answered 404. Try again in a moment. | 專案還沒有模擬器建置版本 | 請 Agent 建置專案，然後重試 |
| 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/tw/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"}}
```
