Contributing to zero-native
Thanks for your interest in contributing! This guide covers building the framework from source, running the test suites, and the strict compatibility rules that keep OTA updates safe for apps already in the wild.
1. Local Development Setup
Section titled “1. Local Development Setup”git clone https://github.com/zero-native/zero-native.gitcd zero-nativebun installRun all JS & type tests
Section titled “Run all JS & type tests”bun run sample:js # compiles examples/sample (also seeds test-kit fixture data on fresh clone)bun run test # runs bun test across packages, plugins, compiler, tools, server + tscAndroid runtime tests & lint
Section titled “Android runtime tests & lint”From android/:
./gradlew :runtime:testDebugUnitTest :runtime:lintDebug :sample:lintDebug./gradlew :sample:installDebugiOS runtime & C++ core tests (macOS)
Section titled “iOS runtime & C++ core tests (macOS)”bun run tools/fetch-hermes-apple.tsbun run tools/run-core-tests-apple.ts --simbun run tools/ios-sample.tsThe sample app
Section titled “The sample app”examples/sample is the framework’s test bench (every component, lab screens for each feature). You need Android
Studio for Android, and a Mac with Xcode 26 and CMake (brew install cmake) for iOS.
-
Android, from
android/:./gradlew :sample:installDebug. While you work on screens,bun run devsends saved changes to the debug build on the phone in under a second. Release builds (:sample:installRelease) are for measuring. -
iOS simulator: open one (
open -a Simulator), thenbun run tools/ios-sample.tsbuilds the sample, installs it and starts it with its console attached (about a minute the first time).--link zn://sample/dev/rn-propsstarts on a screen by its link; the other options (another simulator, slow animations, touch logging) are at the top oftools/ios-sample.ts. Lottie and Firebase are optional:bun run tools/fetch-lottie-apple.ts,bun run tools/fetch-firebase-apple.ts, and your ownios/Sample/GoogleService-Info.plist(never committed); without them those plugins answer “unavailable”. More in milestones-ios.md. -
Your own iPhone: sign with your Apple team (
-DZN_TEAM) and use release Hermes:Terminal window bun run tools/fetch-hermes-apple.ts releasecmake -G Xcode -S ios -B ios/build/device -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DZN_TEAM=<your team id> -DZN_HERMES_DIR=$PWD/ios/third_party/hermes/release/destrootxcodebuild -project ios/build/device/zn_ios.xcodeproj -target ZnSample -sdk iphoneos -configuration Release -allowProvisioningUpdates buildxcrun devicectl device install app --device <device id> ios/build/device/Release-iphoneos/ZnSample.appThe console prints
app: first frame … ms after the process startedandnav: first screens up …on each launch. -
An app on this checkout (to try unreleased changes):
bun run tools/zn.ts new ../my-app(getting started §6).
The four v0 experiments that started the project are in experiments/.
Code generators
Section titled “Code generators”bun run gen:registry— validatespackages/template/src/registry.tsagainstregistry.lock.jsonand regenerates Kotlin/Swift registry files.bun run gen:tag-props— regeneratescompiler/src/tag-props.tsfrompackages/ui/src/index.ts.
CI runs JS tests, type checks, C++ core tests, ios:ota-test, tools/pack.ts, Android lint (:runtime and :sample) + unit tests across every module + R8 release build, iOS simulator + Release + SwiftPM (SamplePackage) builds, and a fresh zn new app build on every PR.
2. The Registry Rules (Keeping OTA Backward-Compatible)
Section titled “2. The Registry Rules (Keeping OTA Backward-Compatible)”Compiled .zn.ui templates store numeric IDs (for components, props, events, and enums) from packages/template/src/registry.ts, not string names. Because older app binaries stay installed on users’ phones for months, every change to the registry must obey these rules (enforced automatically by bun run gen:registry and tests):
- Never remove, rename, renumber, or retype an existing entry. Old bundles depend on those IDs. If something is deprecated, mark it unused in a comment.
- When adding a component, prop, event, or enum value (or making a static prop dynamic):
- Increment
REGISTRY_VERSIONby 1 (once per PR/feature, not once per entry). - Add each new entry to
Addedat the bottom ofregistry.tswith the new version number.
- Increment
- Never silently change the behavior of an existing entry. Add a new prop or enum value instead so older screens don’t change unexpectedly.
- Run both generators:
The compiler uses
Terminal window bun run gen:registrybun run gen:tag-propsAddedto compute the minimumregistryVersioneach bundle requires — so apps that don’t use a new feature can still deliver OTA updates to older store builds!
3. Adding a New Component (Checklist)
Section titled “3. Adding a New Component (Checklist)”- Registry (
packages/template/src/registry.ts): Add component, prop, and event IDs, bumpREGISTRY_VERSION, list them inAdded, and runbun run gen:registry. - Types (
packages/ui/src/index.ts): Add the JSX component & prop types with clear JSDoc, then runbun run gen:tag-props. - Compiler (
compiler/src/compile.ts): Only touch if the component needs special compile-time handling. - Android (
android/runtime/): ImplementZn<Name>.ktusing Compose Foundation only (no Material 3), wire it inZnRenderer.ktandZnTemplate.kt. Dynamic props must read fromDynamicPropsslot cells. - iOS (
ios/ZnRuntime/Swift/): Implement the matching SwiftUI/UIKit view and wire it in the renderer. - Sample & Docs: Add a test lab in
examples/sample/src/, document the component indocs/components.md(and note any platform differences indocs/platform-differences.md). - Verify: Run
bun run sample:js && bun run test, Android tests/lint, and iOS build.
4. Changing the Host API / Bridge
Section titled “4. Changing the Host API / Bridge”- App event IDs (native → JS events on instance
0) must match exactly betweenpackages/core/src/app-events.tsand native (ZnAppEvent.kt/ Swift). Tests enforce equality. - Adding a
__zn_*host function, app event, or batch op requires bumpingkHostApiVersionincore/include/zn/engine.handHOST_API_VERSIONinpackages/core/src/host-api.tstogether. - Breaking/removing an existing host function requires bumping
kHostApiOldest, which drops compatibility with older bundles — discuss in an issue first.