CLI (oct build)
Every option of oct build, what it writes per target, and its JSON report.
oct build [--target web,ios,android,mac,windows] [--root .] [--out dist] [--bake] [--viewport 800x600]
[--hermesc <path>] [--hermesc-flags "-O"] [--json]
[--xcframework [--name <Product>] [--embed-runtime] [--runtime <path>] [--remote-url <url>]]oct native types [--schema native-modules.json] [--out src/native.d.ts]
oct native new <Name> [--dir .] [--target <SwiftTarget>]oct build builds your app. oct native helps with native modules: types generates TypeScript declarations from a module schema, and new scaffolds a Swift module and its test.
Options
| Option | Default | Description |
|---|---|---|
--target, -t | web,mac | Comma-separated: web, ios, android, mac, windows |
--root | . | Project root. The app is src/App.tsrx, plus src/styles.css if present |
--out | dist | Output folder, relative to --root |
--bake | off | Write the first-screen snapshot (app.ofrm) for every native target |
--viewport | 800x600 | Reference size (WxH) used while baking to find viewport-dependent styles. Not the size the screen is drawn at |
--hermesc | see below | Path to the Hermes compiler |
--hermesc-flags | -O | Flags for hermesc, space-separated. Add -emit-async-break-check to allow timeLimitMs |
--json | off | Print a JSON report instead of human-readable output |
--xcframework | off | Package the ios / mac targets as a Swift package in dist/<target>-spm (Ship as a Swift package) |
--name | package name | Swift module and product name for --xcframework (example-app becomes ExampleApp) |
--embed-runtime | off | Compile the runtime into <Product>.xcframework instead of shipping Octapus.xcframework next to it |
--runtime | built and cached | Use an existing Octapus.xcframework (also $OCT_RUNTIME_XCFRAMEWORK) |
--remote-url | https://example.com/<Product>/<version> | Base URL of the zips, written to Package.remote.swift |
hermesc is looked up from --hermesc, then $OCT_HERMESC, then the Octapus checkout the CLI was installed from. Native targets fail without it.
The root component is the App export of src/App.tsrx, else its default export, else its first exported function.
Output
| Target | Output |
|---|---|
web | dist/web/: a regular Vite site (index.html, hashed assets) |
ios, mac, android, windows | dist/<target>/: app.js, app.hbc, app.css, manifest.json, and app.ofrm with --bake |
Native output folders are emptied before each build. android and windows produce bundles, but there is no native runtime for them yet.
See manifest.json for the manifest fields.
Compile-time constants
| Constant | Value |
|---|---|
import.meta.env.OCT_TARGET | 'web', 'ios', 'android', 'mac' or 'windows' |
__OCT_TARGET__ | Same value |
Each native target is a separate build, so code behind a check for another platform is removed.
Control stylesheet
A small stylesheet is loaded before src/styles.css on every target, the browser included. It removes platform appearance from button, input and textarea and gives them a plain background, border and padding, so they look the same everywhere. Your CSS overrides it.
JSON report and exit codes
With --json, oct prints one object:
{
ok: boolean,
diagnostics: string[], // compiler messages for App.tsrx ("file:line:col: error: …")
compileMs: number,
compiled: string, // the native compile output of App.tsrx
targets: {
[target: string]:
| { ok: false, ms: number, diagnostics: string[] } // what went wrong
| {
ok: true, ms: number, dir: string,
// native targets also report:
jsBytes: number, cssBytes: number, hbcBytes: number,
hbcFnv: string, // hash pairing app.hbc with app.ofrm
hermesBytecode: number, // Hermes bytecode version
hermescMs: number, hermescWarnings: number,
frame: { ms: number, log: string } | null, // bake result with --bake
}
}
}| Exit code | Meaning |
|---|---|
0 | Every target built |
1 | At least one target failed |
2 | Usage error or unexpected exception |