# Put your game on a phone

> **Note.** Coldwave is in private development: there is no public download yet. These steps apply from the first public release.

`frost export ios` and `frost export android` turn your game into an app for an iPhone or an
Android phone. You do not change the game for a phone: it is the same game, played by
the same player program as on a desktop and on the web, and the same input comes to the
same checksum on all of them. A finger is the pointer (`MouseLeft`), and it fills the
finger slots you name in `[input] fingers`.

Exporting for the web and the desktop is covered in
[your first game](../start/first-game.md#7-export-it). This page is about phones.

> **Note.** Phone exports run in the iPhone simulator and the Android emulator today.
> They have not been tried on a real device, and signing an app for a device or a store
> is yours to do: [see below](export.md#what-only-you-can-do-a-real-phone-and-a-store).

The first downloads will not have the phone players yet: iPhone and Android exports need
a build that has them.

## Make your game ready for a phone

What to write in your game's files so it plays well on a phone, each checked by `frost check`:

```toml
title = "Embers"                 # the app's name under its icon

[window]
size = [960, 540]
orientation = "landscape"        # or "portrait"; left out, from the frame's shape
fit = "fill"                     # the frame takes the screen's shape (below)

[export]
icon = "art/icon.png"            # a square PNG, 1,024 pixels a side for a store

[input]
actions = ["turn", "walk", "jump", "thumb", "start"]
# A stick on the left half and a JUMP button on the right while the node `panel` is
# hidden (in play), and START pressed where the title draws it while `panel` is shown.
fingers = [
    { region = { x = -1, y = -1, w = 1, h = 2 }, x = "turn", y = "walk", press = "thumb", stick = 0.15, shown = true, while_hidden = "panel" },
    { region = { x = 0.4, y = -1, w = 0.6, h = 1.2 }, press = "jump", label = "JUMP", shown = true, while_hidden = "panel" },
    { region = { x = -0.21, y = -0.2, w = 0.42, h = 0.15 }, press = "start", while_shown = "panel" },
]
controls = { alpha = 0.35 }      # how the drawn controls look: color, alpha, size
```

The `embers` template's own `game.toml` shows the fill and finger settings, and
`frost reference` describes every key above. Then run `frost export ios` or
`frost export android`, below.

## On a phone

- **The screen.** The frame is fitted inside the phone's safe area (clear of the notch or
  the Dynamic Island, the cutout and the home bar), and the background's colour runs under
  the rest. The safe area is no input of the game's: no script reads it and no checksum
  moves with it. The pointer and fingers are found in the frame where it is drawn.
- **The frame's shape.** Left as it is (`fit = "letterbox"`), the frame keeps its size and
  shape, and a phone longer than it has bars beside it. With `[window] fit = "fill"` the
  player gives the frame the shape of the safe area when it starts: the project's height
  is kept and the width grown to the screen's (for a frame taller than it is wide, its
  width kept and the height grown), and it prints `the frame fills the screen: W by H`.
  The game sees that frame: `frame.size()` returns it, interface nodes anchored to an edge
  follow that edge, a 3D camera sees further to the sides, and a 2D game draws more of its
  world. A game that fills is made to be right at any width, which is worth trying with
  `frost run --size WxH` (a phone on its side is about 2.1 times as wide as it is tall).
- **The shape is input.** A run at another frame than `[window] size` comes to another
  checksum, so the frame is part of what a recording says: a run at another shape writes
  `frame = [W, H]` at the head of its recording (`input.history`), as `[input] frame` in a
  project file, and `frost run`, `frost test` and the player's `--hold` replay it in that
  frame. A recording with no `frame` replays at `[window] size`, as every recording made
  before did. Embers has both: a run at an iPhone's shape with its own checksum
  and its ordinary run at 960 by
  540.
- **Away and back.** Sent to the background, the game stops where it is: nothing is drawn
  or stepped and its sound is held. Back, its window's surface is made again (Android takes
  it away), the sound goes on, and its clock starts from then: the time away is not played.
  The player prints `away at step N` and `back at step N`.
- **Which way up.** `[window] orientation = "landscape"` or `"portrait"`; left out, landscape
  for a frame wider than it is tall.
- **Name and icon.** The app is named by the project's `title` (else its folder) and shows
  `[export] icon`, a square PNG file, 1,024 pixels a side for a store (`E0534` when it is
  not a square PNG). On iOS it is compiled into the app by Xcode's `actool`, on Android it
  is the apk's one resource.
- **Touch controls with no script.** A finger slot with `stick = R` is a stick (its `x` and
  `y` are the thumb's way from where it came down, over R of the frame's heights), one with
  only a `press` is a button, and `shown = true` has the player draw it over the game: a
  stick a ring with a knob that follows the thumb, a button a disc with its `label`, at a
  thumb's size in points inside the safe area, see-through at rest and brighter while
  pressed, never over a shown interface node. `while_hidden = "panel"` / `while_shown`
  keeps a slot to the moments its node says (Embers: START on the title, the stick and
  JUMP in play), and `[input] controls = { color, alpha, size }` restyles them all. The
  player's picture, not the game's world.

## iOS

```
frost export ios GAME.toml --out DIR [--device] [--recording] [--any-engine]
```

writes `DIR/NAME.app`: the player named after the game, `Info.plist` and the game's files
in `game/`. It is for the iPhone simulator on a Mac with Apple silicon
(`aarch64-apple-ios-sim`) unless `--device` asks for an iPhone (`aarch64-apple-ios`). The
app is full screen with no status bar, held the way `[window] orientation` says. Its id is the project's `id` (or `dev.coldwave.` and the game's name), printed by
the export. It is not signed: the simulator runs it as it is, and an iPhone runs nothing
that is not.

Needs: Xcode with its iOS platform (`E0500` without it) and `rustup target add
aarch64-apple-ios-sim` (`aarch64-apple-ios` for `--device`).

To play it in a simulator with no window (the Simulator app is not needed):

```sh
xcrun simctl boot "iPhone 17"
xcrun simctl install "iPhone 17" DIR/NAME.app
xcrun simctl launch --console-pty "iPhone 17" APP_ID          # what the player prints
xcrun simctl launch --console-pty "iPhone 17" APP_ID --hold 600   # held at step 600 of a recording exported with --recording
xcrun simctl io "iPhone 17" screenshot shot.png
```

## Android

```
frost export android GAME.toml --out DIR [--recording] [--any-engine]
```

writes `DIR/NAME.apk` for arm64 phones and emulators (`arm64-v8a`, Android 8.0 and later,
API 26: the first with AAudio, which sound goes through). The app has no Java: the
system's own `NativeActivity` loads the player, `lib/arm64-v8a/libfrost_player.so`, and the
game's files are the apk's assets (`assets/game/`, named in `assets/ven-files.txt`). It
is signed with a debug key the export makes once, in the build folder
(`target/players/android-debug.keystore`): it installs on an emulator or a phone with
USB debugging, and no store takes it.

Needs: the Android SDK with `build-tools`, a platform and the NDK (found from
`ANDROID_HOME`, `ANDROID_NDK_HOME`, or `~/Library/Android/sdk`; `E0535` names what is
missing), Java's `keytool`, and `rustup target add aarch64-linux-android`. Nothing is
downloaded: no Gradle. `E0529` is a program of the SDK that failed, with what it said.

```sh
adb install -r DIR/NAME.apk
adb shell am start -n APP_ID/android.app.NativeActivity
adb logcat -s frost_player                         # what the player prints
adb shell setprop debug.ven.args.APP_ID "'--hold 600'"  # the arguments after game.toml, for the next start
adb exec-out screencap -p > shot.png
```

An app is started with no command line, so the player takes its arguments from the system
property `debug.ven.args.APP_ID` (a test's `--hold N`); set it to `' '` to play live again.
Each app reads its own property and no other's. Whoever has `adb` can set it, for a
shipped game too, so what it can ask for is kept small: `--out` takes a file's name
there, not a path, and the picture is written to `files/pictures/NAME` in the app's own
folder (a path could have named the game's save).

What an Android app does that a desktop's program does not:

- **A game that ends, ends its process.** Android keeps an app's process after its
  screen is gone and starts the app in it again; the player cannot start twice in one
  process, so when the game ends (it failed, or a test's `--picture-at` is written) its
  activity is finished, the process ends with it and the next start is a new one.
- **One of the game at a time.** The activity is `singleTask`: a second start, from the
  launcher or from another app, brings the running game forward and makes no second one.
- **A setting changed while the game runs** (the font's size, the language, dark mode,
  a keyboard plugged in) does not restart the game: the apk's manifest says the app takes
  every such change itself, and the game draws nothing from the system's resources.
- **Not handled: an activity the system destroys while its process lives.** That is the
  developer option "Don't keep activities", and any change of the phone's the manifest has
  no name for (the one name that covers them all, `resourcesUnused`, is read by Android
  16 and later). The game then stops answering and the system offers to close it; started
  again, it starts from the beginning. A fix is being built.

## Sizes

How big an exported app is, measured on 27 Nov 2026 on macOS on Apple silicon:

| Game | iOS simulator app | Android apk (its player before the apk compresses it) |
| --- | --- | --- |
| An empty game | 2,442,412 bytes | 1,626,661 bytes (3,141,104) |
| A 2D game with scripts | 3,717,853 bytes | 2,327,211 bytes (4,816,200) |
| A 3D game with scripts and physics | 4,513,243 bytes | not measured alone |

## How it is tested

Phone exports are tested in the iPhone simulator and an arm64 Android emulator, not yet
on a real device. In both, an exported game replays a recorded run and must stand at the
same checksum `frost run` prints on the desktop, with the game on the screen.

On Android the tests go further, since that is where an app meets a system least like a
desktop's:

- Embers' whole recorded run of 2,653 steps comes to the desktop's checksum.
- The player's own picture of a step is compared with the desktop's: pixel for pixel for
  a 2D game, and for Embers within a small bound, because the emulator draws in software
  (measured: 0.6% and 1.6% of pixels differ, nearly all by one level).
- Taps on the screen reach the finger slots where the finger was.
- A game that ends leaves no process behind and starts again cleanly, and a saved game
  written by one start is read by the next.
- The font size changed under a running game does not restart it.
- Embers was sent to the background and brought back thirteen times: a finger still
  turned it afterwards, it held no more memory, threads or open files after the last
  five times than before them, and the system logged no crash and no "not responding".

On iOS there is no touch test yet: nothing can touch a simulator's screen without
opening its window.

## What only you can do: a real phone, and a store

Each needs an account and a key that are yours, which the engine never holds.

**An iPhone.** An Apple Developer account (free for one's own phone, paid for TestFlight
and the App Store), a signing identity and a provisioning profile for the app's id, made in
Xcode or at developer.apple.com.

```sh
frost export ios game.toml --out out --device
cp ~/Downloads/NAME.mobileprovision out/NAME.app/embedded.mobileprovision
security cms -D -i out/NAME.app/embedded.mobileprovision > profile.plist
/usr/libexec/PlistBuddy -x -c 'Print :Entitlements' profile.plist > entitlements.plist
codesign --force --sign "Apple Development: YOUR NAME (TEAMID)" --entitlements entitlements.plist out/NAME.app
xcrun devicectl device install app --device DEVICE_ID out/NAME.app
```

For the App Store: an "Apple Distribution" identity and an App Store profile in place of
the two above, then `mkdir Payload && cp -R out/NAME.app Payload/ && zip -r NAME.ipa
Payload` and `xcrun altool --upload-app -f NAME.ipa -t ios --apiKey KEY --apiIssuer
ISSUER` (or Transporter). The store needs the app's icon, which the export makes from
`[export] icon`; with none the app has no icon and the store refuses it.

**An Android phone.** Developer options and USB debugging on, then `adb install -r
out/NAME.apk` installs the debug-signed apk as it is. For Google Play: a key of one's own,
kept for the life of the app, and the apk signed with it in place of the debug key:

```sh
keytool -genkeypair -keystore release.keystore -alias release -keyalg RSA -keysize 4096 -validity 10000
apksigner sign --ks release.keystore --ks-key-alias release --out NAME-release.apk out/NAME.apk
```

Google Play takes new apps only as an Android App Bundle (`.aab`), which needs
`bundletool` (the export does not make a bundle yet); other stores and direct downloads
take the signed apk. You need a Play developer account of your own.

## Not done yet

- Signing for an iPhone or a store, an `.ipa` or an `.aab`, and uploading: all yours to
  do, above. The export never holds a key, an account or a profile.
- A launch picture, a version number other than 1.0.
- A frame that fills is given its shape once, when the player starts; the phone is held one
  way (`orientation`), so the screen does not change shape under it.
- Recording on a phone: the player plays and replays, it writes no recording. A run at a
  phone's shape is recorded on a desktop, by a tool over the protocol: `game.reset` with a
  `width` and `height`, the game played, then `input.history`.
- Android on x86_64 (an emulator image for Intel Macs), and a phone that is not arm64.
- An automated touch test on iOS.
- Saves: on Android they are kept in the app's own folder, under `.local/share` there;
  on iOS in the app's container under `.local/share`, not the system's `Library`.
- An Android activity destroyed while its process lives (above).
- Sound is built for both, but nobody has listened to it on either yet.
