# waitForApp

Launch an app if necessary and wait for its helper.

```js
waitForApp(bundleId, timeout = 12)
```

## Arguments

| Argument | Type | Meaning |
| --- | --- | --- |
| `bundleId` | string | Target app identifier. |
| `timeout` | number | Seconds; default 12. |

## Returns

No return value (`undefined`). Timeout also returns without a success value.

## Example

```js
waitForApp("com.apple.Preferences", 8);
if (frontMostAppId() !== "com.apple.Preferences") throw new Error("Not foreground");
```

## Notes

Use UIHelper.waitForElement afterward to verify UI readiness.

[All JavaScript APIs](https://mcp.applesauceos.com/doc/api.md) · [Automation playbook](https://mcp.applesauceos.com/doc/ai.md)
