Build, run & install

When your app closes by itself in Preview, have an Agent read the device's log while you repeat what you did, find the error and fix it.

When your app closes by itself in Preview, or a screen stops working, the device’s log can show why. Preview has no log view. An Agent reads the log of the device you’re looking at with simulator logs (see logs in simulator), tells you what went wrong and fixes it.

On iPhone and iPad, the log is live

On iPhone and iPad devices, the log isn’t a history. The Agent sees only what the app writes after it starts reading. So the order matters: the Agent starts reading first, then the crash happens again. Either you do the steps again in Preview, or the Agent does them itself on the same device.

Ask an Agent

  1. Note the device you’re looking at: its name is on the device menu, in the navigation bar on iPhone and over the device on the Mac.

  2. In the project’s chat, say what you did, step by step, and what happened. Name the device, for example:

    On the iPad in Preview, the app closes when I tap Save on a new note. Start reading its log, tell me when you're ready, and I'll do it again.
  3. When the Agent says it’s reading, do the same steps again in Preview, soon: it reads for a set time.

  4. The Agent reads what the app wrote, tells you in the chat which error it found and what causes it, and fixes the code.

  5. It builds the app again. When the new build is on the device, the chat shows New version ready. See Open the Preview when a new build is ready.

  6. Do the steps again and check that the app stays open.

To point at the screen where it happens, use Screenshot or Draw in Preview before you send the message. See Run your app in Preview.

If the steps are easy to describe, you can leave the whole thing to the Agent:

The app closes when I tap Save on a new note. Do it yourself in Preview while you read the log, then find the cause and fix it.

What the Agent can read on iPhone and iPad

Option What it keeps
Your app only (--app) Your app’s lines and its extensions’ lines, for example a widget’s.
A level (--level) Lines at that level or above: debug, info, warn, error, fatal.
A set time (--follow --duration) What’s written while the Agent reads; then the read stops.

On iPhone and iPad, both filters work on the device itself. So when the Agent reads only your app, it doesn’t lose lines the way it can when it reads everything the device writes.

If you tap Reinstall (on iPhone, the app’s icon) while the Agent follows only your app’s lines, its read ends. Tell the Agent, so it starts again before you repeat the steps.

On an Android phone (beta)

On an Android phone the log is Android’s own, and Android keeps a separate log of crashes. The simulator help tells an Agent to start with that crash log (--crashes) when an app closes itself. Your app’s lines (--app) include its crash too, even after the app was opened again. So you can ask after it happened:

The app just closed on the Android phone in Preview when I opened Settings. Find out why and fix it.

The levels on Android also include verbose. For Android in Preview, see Make an Android or PocketJS version (beta).

Questions

The Agent found nothing from my app in the log.
On iPhone and iPad, the log holds only what’s written after the Agent starts reading. Ask it to start again, wait until it says it’s reading, then do the steps again. If you tapped Reinstall in between, its read ended: ask it to start again too.
The Agent says some lines were dropped.
When a device writes lines faster than they can be carried, some are dropped, and the log marks the spot. Ask the Agent to read only your app’s lines, which loses fewer.
Can I read the log myself?
Not in AirBuild: Preview has no log view. Ask the Agent to paste the lines that matter in the chat. Live Logs in AirBuild is your backend’s log, not the app’s: see Check your backend’s logs and deploys.
It only goes wrong the first time the app opens.
Ask the Agent to remove the app and install it again, then read the log while you open it. See Start your app fresh in Preview, like a first-time user.
Nothing crashes, but a Siri, Spotlight or iCloud feature does nothing.
Preview devices start with some services turned off. See Make Siri, Spotlight or iCloud work in Preview.
Preview says “Unable to Run App”.
The app couldn’t be installed or opened at all. See the table in Run your app in Preview.
My app crashes for people who downloaded it.
Those crashes arrive in AirFeedback, if your app collects them. See Collect feedback and crashes (AirFeedback).