Building an app

tosijs-native build makes an app's native shells from its config. The app is a folder holding tosijs-native.config.ts and a web build; the command wraps what is there and never edits it.

Status (2026-11-30, board #4247, #4435): it builds for iOS, macOS and Android. Every build it makes has run in the Simulator, in the emulator or on this Mac, and the Android builds of the examples install and open on a Samsung Galaxy A17 (with the debug key), and the iOS device builds on an iPhone 14 Pro and 17 Pro Max (with a team development profile), 2026-12-03. On those phones the owner saw Notes' own icon and name on the iPhone, and the Material look on the A17 and Glass on the iPhones, in light and dark. None has been signed for a store. The package is on npm (bun add tosijs-native). While working on tosijs-native itself, link it into an app (bun link in this repo, then bun link tosijs-native in the app) rather than installing it from a folder: a file: dependency is a copy, and the command refuses to build from a stale one.

The shortest app

// tosijs-native.config.ts
import { defineConfig } from 'tosijs-native'

export default defineConfig({
  appId: 'net.example.notes',
  name: 'Notes Example',
  shortName: 'Notes',
  products: [],
  achievements: [],
  targets: ['web', 'ios', 'mac-direct', 'android'],
  capabilities: { files: true, share: true },
  icon: { square: 'icon.svg', background: '#1d3557' },
})
bun build.ts                        # your own web build, into dist/ (whatever builds it)
bunx tosijs-native doctor           # what this machine is missing, for the config's targets
bunx tosijs-native build            # every target the config lists that can be made here
bunx tosijs-native build --target ios
bunx tosijs-native run --target ios # build, install and open it in the Simulator

examples/notes is this app, whole. examples/feed checks a site every 15 minutes in the background and notifies on a change, examples/radio plays on in the background with the system's media controls, examples/trail records a route, in the background too, and examples/catalog shows the native controls the examples share (below). The config's fields are documented in src/config.tjs (the Config page on the site), and typed in the package's index.d.ts.

The examples are built with tosijs and tosijs-ui, and look native where they run: Material on Android, Glass on iOS and macOS, chosen from native.target by examples/shared/look.ts (each passes its icon's colour as the accent). That file is the examples' own, not part of the package: an app chooses its look. On the web, ?look=glass or ?look=material previews another platform's look in a browser.

examples/shared/controls holds native controls written as tosijs-ui components, offered to it (tosijs-ui #4684): a page with its top bar, a stack of pages pushed and popped as each platform does it (iOS's edge swipe, Material's shared axis; every push a history entry, so Android's Back goes back a page), a bottom tab bar, and list rows for tosijs's virtual lists. Each follows the platform its look is drawn for, read from --tosi-nav-style. A stack can show several pages side by side (columns), as iPadOS's split view, the Mac's sidebar and Material's list-detail layout do: as many as the width fits, so the same stack pushes on a phone held upright and keeps its list beside the detail sideways, on an iPad or in a wide window. The catalog's Lists tab shows three.

What it makes

Builds go to native/ beside the config. The folder ignores itself in git.

target made by what you get signed with
ios the Swift shell native/ios-simulator/<Name>.app ad hoc, for the Simulator
ios --device the Swift shell native/ios/<Name>.app the identity and profile you name, or nothing
mac, mac-direct the Swift shell native/mac/<Name>.app ad hoc: it runs on this Mac
android the Kotlin shell native/android/<Name>-<version>.apk and .aab the keystore you name, or the debug key
web nothing the web build is the app
windows, linux, steam not yet build skips them and says so

native/work/ holds intermediates: the staged web build, the icons, compiler caches. It can be deleted at any time. The package's own folder is only read, so it builds the same from node_modules.

A build compiles the shell for the app. From an empty native/, on the Mac this was measured on and with the compilers already warm: iOS 6 s, the Mac app 7 s, Android 5 s. The first build after a restart is slower (the Mac app took 15 s, all three targets 25 s).

The config decides what the app may do

The command writes the config into the app as a file the page cannot change, and builds the app with only what the config declares:

bun run examples checks this from both sides for each example: inside a debug shell the example's page asks for what it did not declare and must be refused, and the release build is read back (its id, name, version, permissions, background modes, orientation and launch screen). bun run examples trail ios runs one example on one target.

How it looks before the page

orientation ('portrait', 'landscape' or 'any') becomes the Info.plist's supported orientations for iPhone and iPad, and Android's screenOrientation (userPortrait, userLandscape: they keep to the player's rotation lock). iPadOS letterboxes an app that will not turn; Android 16 ignores the setting on screens 600 dp and wider for apps that are not games.

launch is drawn twice, so it looks like one screen (CAPABILITIES.md, decision 13): as the system's launch screen (an iOS storyboard compiled with ibtool; Android's theme, which from Android 12 can show only the colour), and as the shell's own view over the web view until the page calls native.ready(), or three seconds after it loaded. The image, SVG or PNG, is drawn at each size the platforms need by bin/raster.swift (AppKit), so building an app with a launch image needs a Mac, as the iOS and Mac builds do anyway.

Signing

The command uses only what it is told, and never looks in a keychain.

Not built yet