Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Platform Overview

Perry compiles TypeScript to native executables for 9 platform families from the same source code.

Supported Platforms

PlatformTarget FlagUI ToolkitStatus
macOS(default)AppKitFull support (127/127 FFI functions)
iOS--target ios / --target ios-simulatorUIKitFull support (127/127)
visionOS--target visionos / --target visionos-simulatorUIKit (2D windows)Core support (2D only)
tvOS--target tvos / --target tvos-simulatorUIKitFull support (focus engine + game controllers)
watchOS--target watchos / --target watchos-simulatorSwiftUI (data-driven)Core support (15 widgets)
Android--target androidJNI/Android SDKFull support (112/112)
Windows--target windowsWin32Full support (112/112)
Linux--target linuxGTK4Full support (112/112)
Web / WebAssembly--target web (alias --target wasm)DOM/CSS via WASM bridgeFull support (168 widgets)

Cross-Compilation

# Default: compile for current platform
perry app.ts -o app

# Compile for a specific target
perry app.ts -o app --target ios-simulator
perry app.ts -o app --target visionos-simulator
perry app.ts -o app --target tvos-simulator
perry app.ts -o app --target watchos-simulator
perry app.ts -o app --target web   # alias: --target wasm
perry app.ts -o app --target windows
perry app.ts -o app --target linux
perry app.ts -o app --target android

Platform Detection

Use the __platform__ compile-time constant to branch by platform:

declare const __platform__: number;

// Platform constants:
// 0 = macOS
// 1 = iOS
// 2 = Android
// 3 = Windows
// 4 = Linux
// 5 = Web (browser, --target web / --target wasm)
// 6 = tvOS
// 7 = watchOS
// 8 = visionOS

if (__platform__ === 0) {
  console.log("Running on macOS");
} else if (__platform__ === 1) {
  console.log("Running on iOS");
} else if (__platform__ === 3) {
  console.log("Running on Windows");
}

__platform__ is resolved at compile time. The compiler constant-folds comparisons and eliminates dead branches, so platform-specific code has zero runtime cost.

Platform Feature Matrix

FeaturemacOSiOSvisionOStvOSwatchOSAndroidWindowsLinuxWeb (WASM)
CLI programsYesYesYes
Native UI (DOM on web)YesYesYesYesYesYesYesYesYes
Game enginesYesYesYesYesYesYesVia FFI
File systemYesSandboxedSandboxedSandboxedSandboxedYesYesFile System Access API
NetworkingYesYesYesYesYesYesYesYesfetch / WebSocket
System APIsYesPartialPartialPartialMinimalPartialYesYesPartial
Widgets (WidgetKit)YesYes
ThreadingNativeNativeNativeNativeNativeNativeNativeNativeWeb Workers

Next Steps