tvOS
Bern compiles the tvOS target (platform = "tvos") to a native SwiftUI Apple TV application targeting tvOS 18 or newer. tvOS targets must be built on a Mac.
Prerequisites
- macOS host with Rust 1.99+ and Xcode 26 or newer (with the tvOS platform SDK and Apple TV simulators installed).
- Add the Rust targets for the tvOS simulator and Apple TV hardware:
# On Apple Silicon Macs (use x86_64-apple-tvos on Intel Macs)
rustup target add aarch64-apple-tvos-sim aarch64-apple-tvos
bern doctorConfiguration in Bern.toml
[app]
id = "tasks"
bundle_id = "com.example.tasks"
version = "0.1.0"
name = "Tasks"
[app.icon]
default = "assets/icon.png"
tvos = "assets/AppIcon.brandassets" # Optional: .brandassets or square PNG
[targets.tvos]
platform = "tvos"
ui = "swiftui"When [app.icon].tvos is omitted (or points to a square PNG), Bern automatically synthesizes the layered tvOS home screen app icon and Top Shelf image from the default icon.
Build, run, and debug
# Check tvOS declarations
bern check --target tvos
# Build for the tvOS simulator
bern build --target tvos
# Launch on an Apple TV simulator with IPC connected
bern run --target tvosDrive the running simulator app with the generated app CLI using --engine tvos:
target/bern/tvos/bin/tasks --engine tvos window screenshot --output tvos.pngUseful debugging environment variables:
| Variable | Effect |
|---|---|
BERN_APPEARANCE=light|dark |
Overrides appearance for inspection. |
BERN_MOTION=reduce|slow |
Reduces motion or slows spring animations 10×. |
BERN_TRACE=<rules> |
Enables performance tracing. |
BERN_SNAPSHOT_DIR=<dir> |
Saves automatic window snapshots. |
Platform behavior and adaptations
- Compile-time TV specialization:
window.tvis staticallytrueon tvOS. Bern keeps onlyLayout(size: tv)branches inAdaptive, appliesfont(tv:)typography sizes fromstyle!blocks, and prunes desktop/phone/watch layouts at compile time. - Siri Remote & Focus Engine:
- Set
default_focus: trueon the primaryButtonorIconButtonin a view so focus lands reliably when a screen or modal opens. Shortcutmaps remote buttons without needing a visible control:escapemaps to Menu/Back,spacemaps to Play/Pause, and arrow keys fire when focus cannot move further in that direction.- On full-screen media screens where controls are hidden, a full-screen focus target lets directional arrows act as seek/skip shortcuts.
- Set
- Windows and overlays: Secondary windows open as
fullScreenCover;Popoveropens as a sheet;Tablelowers to a single-column list of focusable row buttons. - Media and SVG: Custom
MediaKernelreceives aCAMetalLayerandCADisplayLinkframe clock. AnimatedSvgcompiles to pure-RustBSVGbytecode (no WebKit dependency); static SVGs rasterize to PNGs. - Unavailable capabilities:
file_pick,paste:,WebPage,MenuBar,StatusItem,wheel,slider_hover,scroll_anchor,scroll_browsing,bound_blur, and runtime alternate icons are not available on tvOS. Keep pointer-only UI inside non-tvAdaptivebranches sobern check --target tvosstays clean. - Native views: Co-located SwiftUI/UIKit tvOS views mount via
NativeView(tvos: "..."). See Native views.
Packaging and signing
bern package --target tvosbern package --target tvos builds the release arm64 bundle and writes an ad-hoc .ipa to target/bern/dist/. Re-sign with your Apple distribution certificate and tvOS provisioning profile before installing on an Apple TV or submitting to App Store Connect.