# AI use cases for Mobilecode (hsandhu/mobilecode)

Repo: [hsandhu/mobilecode](https://github.com/hsandhu/mobilecode) | Use cases: 3 | Page: https://dedupedai.com/use-cases/hsandhu-mobilecode/

MobileCode is an open source fork of opencode, an AI coding agent, that detects iOS and Android projects and previews them in a simulator or emulator beside your session.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Preview a React Native app on iOS and Android at once: https://dedupedai.com/use-cases/hsandhu-mobilecode/preview-react-native-app-on-ios-and-android/
- Let an agent fix a failing mobile build on its own: https://dedupedai.com/use-cases/hsandhu-mobilecode/let-agent-fix-failing-mobile-build/
- Run MobileCode from source to change it: https://dedupedai.com/use-cases/hsandhu-mobilecode/run-mobilecode-from-source-for-development/

## How to preview a React Native app on iOS and Android at once with Mobilecode

Repo: [hsandhu/mobilecode](https://github.com/hsandhu/mobilecode) | Difficulty: Intermediate | Time: 1 hour | Basis: From the README

Run one React Native project on both simulators from a single MobileCode session.

**Who it is for:** A mobile developer on a Mac with a React Native or Expo app who wants to see iOS and Android builds side by side while coding.

**The problem:** Setting up Metro, simulators, emulators, and native builds for two platforms by hand is slow and easy to get wrong.

**The outcome:** Both platforms run the same project in the device pane, with one shared Metro server.

### Steps

1. Run `curl -fsSL https://raw.githubusercontent.com/hsandhu/mobilecode/main/install | bash` to install MobileCode.
2. Open the React Native project folder as a session in MobileCode. Projects up to two directories below the session root are detected.
3. Click Play on the iOS control in the session titlebar. The iOS simulator starts, the app builds, installs, and launches.
4. Click Play on the Android control. The emulator starts and connects to the same Metro server that iOS already started.
5. Use Stop on one platform to end only that run. Metro stays up while the other app is still running.

### Prompt to paste into your agent

```text
Using the MobileCode repo at https://github.com/hsandhu/mobilecode, start the iOS and Android previews for the React Native project at <project-path> through its device-preview HTTP endpoints (POST /api/device-preview/run with platform ios, then android). Report the run status for each platform. Before reporting success, confirm with GET /api/device-preview that both platforms show a running state.
```

### Caveat

iOS previews need macOS with Xcode, and the README does not describe support for other hosts.

Risk, remote script: The install command pipes a script from GitHub straight into bash, so read it first or pin a known release before running it.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/hsandhu-mobilecode/preview-react-native-app-on-ios-and-android/

## How to let an agent fix a failing mobile build on its own with Mobilecode

Repo: [hsandhu/mobilecode](https://github.com/hsandhu/mobilecode) | Difficulty: Intermediate | Time: 1 hour 30 minutes | Basis: From the README

The device_run tool builds, launches, reads the error, and retries the fix.

**Who it is for:** A developer whose native iOS or Android build keeps failing and who wants the agent to read the compiler or Gradle output and correct the code without copied logs.

**The problem:** Copying build errors and logs back into a chat is slow, and the fix cycle repeats each time the build breaks.

**The outcome:** The agent runs the app, reads the first build error and log tail, edits the code, and reruns until the app launches or it reports the blocker.

### Steps

1. Run `curl -fsSL https://raw.githubusercontent.com/hsandhu/mobilecode/main/install | bash` to install MobileCode.
2. Open the mobile project as a session. The device pane opens by itself when you open the session.
3. Ask the agent to build and launch the app for the platform that fails, so it calls the device_run tool.
4. Let the agent read the build error and log tail returned by device_run, edit the code, and run again.
5. Watch the status move through Building, Installing, Launching and Running, and open the full build log from the device pane if needed.

### Prompt to paste into your agent

```text
In the MobileCode repo at https://github.com/hsandhu/mobilecode, use the device_run tool to build and launch the <platform> app in the project at <project-path>. Read the build error and log tail on failure, fix the code, and rerun. Report the final status and the changed files. Verify that the last run reached Running before stating the build is fixed.
```

### Caveat

The agent can only fix what the build log shows, so a failure caused by missing SDKs, certificates, or a JDK version still needs you to install the requirement.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/hsandhu-mobilecode/let-agent-fix-failing-mobile-build/

## How to run MobileCode from source to change it with Mobilecode

Repo: [hsandhu/mobilecode](https://github.com/hsandhu/mobilecode) | Difficulty: Advanced | Time: 1 hour | Basis: From the README

Clone the repo, install with Bun, and run the backend, web UI, or desktop app.

**Who it is for:** A developer who wants to modify MobileCode itself or test changes to its mobile preview features before using a release build.

**The problem:** Using a release binary does not let you test changes to the device preview code or the fork's mobile detection.

**The outcome:** A local backend and web UI run from source, and you can run the typecheck and tests before sending a change.

### Steps

1. Run `git clone https://github.com/hsandhu/mobilecode.git` and then `cd mobilecode`.
2. Run `bun install` in the repo root.
3. Run `bun run --cwd packages/opencode src/index.ts serve --port 4096` to start the backend.
4. Run `bun --cwd packages/app dev -- --port 4444` and open http://localhost:4444 for the web UI.
5. Run `bun typecheck` inside the package directory you changed, then `bun test` in packages/opencode before sending changes.

### Prompt to paste into your agent

```text
Clone https://github.com/hsandhu/mobilecode into a local folder, run bun install, then start the backend with `bun run --cwd packages/opencode src/index.ts serve --port 4096`. Expected output: the backend running on port 4096. Verify by confirming the server responds locally before reporting that the source build works.
```

### Caveat

The README gives development commands only and does not describe a contribution process, so check the repo before opening a pull request.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/hsandhu-mobilecode/run-mobilecode-from-source-for-development/
