Skip to Content
Octapus

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

OptionDefaultDescription
--target, -tweb,macComma-separated: web, ios, android, mac, windows
--root.Project root. The app is src/App.tsrx, plus src/styles.css if present
--outdistOutput folder, relative to --root
--bakeoffWrite the first-screen snapshot (app.ofrm) for every native target
--viewport800x600Reference size (WxH) used while baking to find viewport-dependent styles. Not the size the screen is drawn at
--hermescsee belowPath to the Hermes compiler
--hermesc-flags-OFlags for hermesc, space-separated. Add -emit-async-break-check to allow timeLimitMs
--jsonoffPrint a JSON report instead of human-readable output
--xcframeworkoffPackage the ios / mac targets as a Swift package in dist/<target>-spm (Ship as a Swift package)
--namepackage nameSwift module and product name for --xcframework (example-app becomes ExampleApp)
--embed-runtimeoffCompile the runtime into <Product>.xcframework instead of shipping Octapus.xcframework next to it
--runtimebuilt and cachedUse an existing Octapus.xcframework (also $OCT_RUNTIME_XCFRAMEWORK)
--remote-urlhttps://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

TargetOutput
webdist/web/: a regular Vite site (index.html, hashed assets)
ios, mac, android, windowsdist/<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

ConstantValue
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 codeMeaning
0Every target built
1At least one target failed
2Usage error or unexpected exception

On this page