C++ shared by the NativeScript iOS runtime (NativeScript/ios) and Android runtime (NativeScript/android). Both runtimes build against the same V8, and this repository holds the code that does not depend on the platform. The plan and its open decisions are in docs/DESIGN.md.
include/ns/: public headers. Include them as"ns/<Name>.h", never by a bare file name: Xcode header maps resolve bare names project-wide, so a shared header and a runtime header with the same name would collide silently.- Namespace:
nativescript::common, subdivided by component (nativescript::common::base64, …). Never name a nested namespacev8: it would hide::v8insidenativescript::common. src/: implementation. Plain C++20, with no Objective-C and no JNI.- Formatting:
.clang-formatis the iOS runtime's style and CI enforces it (clang-format 22.1.8). A file moved from a runtime and kept comparable with its copy goes in.clang-format-ignoreuntil the migration ends. tests/: host unit tests for the sources that do not need V8.
Core code includes only its own headers, V8 and the standard library. Anything platform-specific goes through an interface the runtime implements (DESIGN.md §4).
Each runtime pins this repository as a git submodule.
| Runtime | Path | Build |
|---|---|---|
| iOS | NativeScript/runtime-common |
RuntimeCommon static library target in v8ios.xcodeproj, linked into NativeScript.framework |
| Android | test-app/runtime/src/main/cpp/runtime-common |
add_subdirectory() from test-app/runtime/CMakeLists.txt, linked into libNativeScript.so |
The library compiles with the including runtime's V8 configuration: its
CMAKE_CXX_FLAGS on Android, its prefix header on iOS. Never set V8
configuration defines (pointer compression, smi size and so on) here; a mismatch
with the V8 build compiles and links, then fails at run time.
- Add it to
NS_RUNTIME_COMMON_V8_FREE_SOURCESorNS_RUNTIME_COMMON_V8_SOURCESinCMakeLists.txt(Android and host tests). - Add it to the
RuntimeCommontarget in the iOS runtime'sv8ios.xcodeproj.
A change here is not done until both runtimes build against it.
cmake -S . -B build -DNS_RUNTIME_COMMON_HOST_TESTS=ON
cmake --build build
ctest --test-dir build --output-on-failureplatform::ParseUrl is a hand-written stand-in by default. Add
-DNS_ADA_DIR=<folder holding ada.h and ada.cpp> (either runtime's vendored
ada) to run the tests against the real WHATWG parser.
Apache 2.0, the same as both runtimes. See LICENSE.