To start diving into the v8 iOS runtime make sure you have XCode and Homebrew installed, and then run the following
# Clone repo
git clone https://github.com/NativeScript/ns-v8ios-runtime.git
# Install CMake
brew install cmake
# Open the runtime in XCode
cd ns-v8ios-runtime
open v8ios.xcodeproj
Select the TestRunner
target and an emulator and hit Run (the play button).
This should take a while, but once built the emulator should start and show a black screen (this is normal). In this phase the app will run all the built-in tests, and report the results to the console:
Runtime initialization took 55ms
2020-09-09 18:30:37.797265+0200 TestRunner[14285:1238340] CONSOLE LOG: Application Start!
2020-09-09 18:30:38.288740+0200 TestRunner[14285:1238340] No implementation found for exposed method "nonExistingSelector"
2020-09-09 18:30:49.720055+0200 TestRunner[14285:1238340] CONSOLE LOG: SUCCESS: 684 specs, 0 failures, 0 skipped, 0 disabled in 11.81s.
If all tests pass, everything is good! At this point you can make changes to the runtime, add breakpoints and step through with the debugger. In the next section we'll see how to attach the runtime to an existing NativeScript application allowing us to debug runtime issues in actual apps.
In the existing app, we need to prepare the XCode project using ns prepare ios
. This should create a folder named platforms/ios
and in there a <appname>.xcworkspace
(if there is no .xcworkspace
use the .xcodeproj
instead). Open it in XCode and then drag the v8ios.xcodeproj
from the ns-v8ios-runtime
folder under the <appname>
in the XCode sidebar.
Remove the NativeScript.xcframework
from the General tab, as we will no longer be using the framework from node_modules and instead will use the source directly:
Hitting Run in XCode should start the app in the simulator, and we can now add breakpoints to the runtime and step through it with the debugger. To apply changes to the javascript, make sure you run ns prepare ios
to re-bundle it into the platforms/ios
folder.
POC showing the {N} iOS runtime running with the V8 engine.
Supported architectures:
- x86_64
- arm64
iOS deployment target:
- 9.0
The --jitless
mode in which V8 is running is explained in the following document
In order to build the V8 engine for iOS and produce the static libraries used in this project follow those steps:
- Get depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"
-
fetch v8
(this will create av8
repo folder automatically checking out themaster
branch) -
cd v8; gclient sync
(this will fetch additional dependencies for building the latest revision)
Ensure you navigate back to root of project: cd ..
-
Apply patches:
apply_patch.sh
-
Run
build_v8.sh
The compiled fat static libraries will be placed inside the v8/dist
folder.
Use the build_all.sh
script included in this repository to produce the dist/npm/nativescript-ios-{version}.tgz
NPM package.