Native pre-boot architecture
ota-nativescript hooks into official NativeScript 9.1 startup points on both platforms so bundle selection, binary-upgrade checks and crash-recovery accounting execute before V8 starts.
OTA Delivery & Atomic Switch
Native pre-boot selects the immutable store-shipped bundle
Before V8 starts, CortexOtaBootstrapper (iOS) / OtaAndroidPlugin (Android) read state.json and boot the untouched embedded bundle.
// active pointer: embedded/app
{
"confirmedReleaseId": null,
"stagedReleaseId": null,
"pendingLaunch": null
}Platform comparison
| Axis | iOS (@nativescript/ios 9.1.1) | Android (@nativescript/android 9.1.3) |
|---|---|---|
| Hook point | NS_SWIFTUI_BOOT = 1 in plugin build.xcconfig suppresses internal/main.m; CortexOtaMain.m calls CortexOtaBootstrapper before NativeScript.runMainApplication. | OtaAndroidPlugin registered via com.tns.internal.Plugin <meta-data>, invoked by RuntimeHelper.initRuntime before asset extraction and V8 startup. |
| Storage root | Library/Application Support/com.getcortexlabs.ota (marked NSURLIsExcludedFromBackupKey). | context.getFilesDir()/ota (app-private internal storage; allowBackup="false" recommended). |
| Embedded fallback | Immutable Bundle.main.resourcePath inside the signed .app bundle. | Extracted from APK assets/app into files/ota/embedded/app once per APK fingerprint. |
| Bundle switching | Passes the selected directory (or Bundle.main.resourcePath) as Config.BaseDir. | Atomically flips files/app via POSIX symlink (Os.symlink to temp link + Os.rename over files/app). |
| Native crypto | Apple CryptoKit (Curve25519.Signing.PublicKey, streaming SHA256) in CortexOtaCrypto.swift. | Google Tink 1.15.0 (Ed25519Verify) + streaming MessageDigest("SHA-256") in OtaCrypto.java. |
| Config delivery | after-prepare writes CortexOtaConfigBase64 + CortexOtaRuntimeContract into Info.plist. | after-prepare writes assets/cortex_ota_config.json into APK assets. |
Why Config.BaseDir and the files/app symlink matter
Both NativeScript's module loader and @nativescript/core's knownFolders.currentApp() resolve relative paths (~/assets/..., ~/fonts/..., dynamic import(...) chunks and new Worker(...)) from the active app root.
Because Config.BaseDir on iOS and the atomic files/app symlink on Android point both V8 and knownFolders.currentApp() at the exact same release directory, entry modules (.mjs/.js), lazy Webpack chunks, web workers, fonts and images always load atomically from one consistent release snapshot.
Entry resolution for NativeScript 9.1 Webpack 5
NativeScript 9.1 Webpack 5 emits .mjs files (bundle.mjs, runtime.mjs, vendor.mjs) while writing extensionless "main": "bundle" in the prepared app/package.json. Both native bootstrappers and ota-ns pack validate entry existence across main, ${main}.mjs and ${main}.js.
Storage layout on disk
<ota-root>/
├── state.json # Atomic rename-swapped BootState
├── embedded/ # (Android only) immutable APK assets/app extraction
│ └── app/
├── staging/ # Isolated download & verification sandbox (wiped on failure)
│ └── <candidateReleaseId>/
└── releases/ # Verified immutable releases (GC keeps active + lastConfirmed + staged)
└── <releaseId>/
├── manifest.json
└── app/
├── package.json
├── bundle.mjs
├── vendor.mjs
├── ota-vue-lazy.mjs
├── src_ota_worker_ts.mjs
├── assets/
└── fonts/