Find out why your app closes or crashes in Preview
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
-
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.
-
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. -
When the Agent says it’s reading, do the same steps again in Preview, soon: it reads for a set time.
-
The Agent reads what the app wrote, tells you in the chat which error it found and what causes it, and fixes the code.
-
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.
-
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).