> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Run on iOS and Android

`ng build --platform` turns your app into a real iOS or Android app, with your app's name and icon. You can install it on a virtual phone or on your own phone. Use it to test what your users will get, and to make the files you upload to the app stores.

**You never open an Xcode or Android Studio project.** The builder generates the native project and builds it for you. You still install Xcode and Android Studio, because their build tools do the compiling.

## Install the tools

Each platform needs its own tools. Install the ones for the platforms you build.

### iOS: a Mac with Xcode

1. **Use a Mac.** Apple only ships its build tools for macOS, so iOS apps can't be built on Windows or Linux.
2. **Install Xcode** from the Mac App Store. It's a large download.
3. **Open Xcode once.** It asks to install extra components and the iOS platform. Accept both. The iOS platform includes the [**iOS Simulator**](/guide/glossary.md#simulator), a virtual iPhone that runs on your Mac.

After that, you can close Xcode. The build calls its command-line tools by itself.

### Android: Android Studio and a JDK


1. **Install [Android Studio](https://developer.android.com/studio)**, on macOS, Windows or Linux. Its setup wizard installs the **Android SDK** (Android's build tools) and the [**emulator**](/guide/glossary.md#emulator), which runs virtual Android phones on your computer.

2. **Keep the SDK's default location**, or set `ANDROID_HOME` to where you put it. The builder looks in:
   - `~/Library/Android/sdk` on macOS
   - `%LOCALAPPDATA%\Android\Sdk` on Windows
   - `~/Android/Sdk` on Linux

3. **Install JDK 17 or newer**, Java's development kit. Android's build needs it. On macOS, the builder finds an installed JDK by itself. Elsewhere, or to use the JDK that comes with Android Studio, set `JAVA_HOME`. For example, on macOS:

   ```bash
   export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"
   ```

4. **Create a virtual phone.** In Android Studio's **Device Manager**, add a virtual device. You don't have to start it: [`--run`](/guide/native-apps/devices.md#run-on-an-emulator-or-android-phone) does.

## Build the apps

```bash
ng build --platform ios       # writes dist/ios/
ng build --platform android   # writes dist/android/
ng build --platform all       # both
```

Each build first makes the bundle, as `ng build` does, then the app around it. You get these files:

| File                           | What it is                                                                                                                                                                                                                               |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dist/ios/MyApp-simulator.app` | An **`.app`**: an iOS app as a folder. This one runs only on the iOS Simulator                                                                                                                                                           |
| `dist/ios/MyApp.ipa`           | An [**`.ipa`**](/guide/glossary.md#ipa): a signed iOS app file for the App Store or [your testers' iPhones](/guide/publishing.md#ios-ad-hoc-ipa). Built once [iOS signing](/guide/publishing.md#ios-app-store-connect-api-key) is set up |
| `dist/android/my-app.apk`      | An [**`.apk`**](/guide/glossary.md#apk): an Android app file you can install directly on an emulator or phone                                                                                                                            |
| `dist/android/my-app.aab`      | An [**`.aab`**](/guide/glossary.md#aab): an Android App Bundle, the file you upload to Google Play. It can't be installed directly                                                                                                       |

The file names come from your app's [`appName`](/guide/native-apps/app-identity.md): `My App` gives `MyApp` on iOS and `my-app` on Android.

- **The first build is slow.** The iOS build downloads a prebuilt copy of the Lynx engine once. The first Android build downloads Android's build system and libraries, which can take several minutes. Later builds take seconds.
- **The native project is hidden.** The builder generates it in Angular's build cache (`.angular/cache/`, which `ng new` already git-ignores). It reuses the project until your options change. `ng cache clean` deletes it, and the next build generates it again.
- **When a build fails,** the error names the full log file. Read the end of it for the tool's own message.

:::info One screen, one bundle
The generated app shows `main.lynx.bundle` full screen, and Angular Router handles all navigation inside it. It doesn't open the other bundles of a [multi-page](/guide/multi-page.md) app. For those, [eject](/guide/native-apps/eject.md) or [embed them in your own app](/guide/embedding/index.md).
:::

## Run the app

Add `--run`, and the build installs the app on a virtual phone and opens it:

```bash
ng build --platform ios --run       # on the iOS Simulator
ng build --platform android --run   # on an emulator or Android phone
```

After a change, run the same command again: the new build replaces the copy that's open.

To choose the phone, name it with `--device`:

```bash
ng build --platform ios --run --device "iPhone 18 Pro"    # a simulator
ng build --platform ios --run --device "Jane's iPhone"    # a real iPhone
ng build --platform android --run --device Pixel_9
```

`--device` names one device, so it goes with `--platform ios` or `--platform android`. `ng build --platform all --run` opens the app on both.

A real iPhone needs a one-time setup first. [Run on simulators and phones](/guide/native-apps/devices.md) covers it, and each kind of device.

## Next steps

- [Run on simulators and phones](/guide/native-apps/devices.md): each kind of device, and `ng serve --platform`, which updates the app as you edit.
- [Set the app identity](/guide/native-apps/app-identity.md): the name, ID, version, icon and splash screen.
- [Turn on device features](/guide/native-apps/device-features.md): Bluetooth, NFC, the camera and the rest.
- [Permissions](/guide/native-apps/permissions.md): the reasons iOS shows when your app asks.
- [Eject the native projects](/guide/native-apps/eject.md): take over the Xcode and Android Studio projects.

## Related

- [Publish to the app stores](/guide/publishing.md): sign and upload.
- [Add native code](/guide/native-plugins/index.md): your own native modules and elements.
- [Build your app](/guide/building-for-production.md): the bundle, budgets and build options.
- [Embed in an existing native app](/guide/embedding/index.md)
- [`@blotch/angular-lynx-build` API](/api/build/index.md) and the [eject schematic](/api/schematics.md#eject)
