Giter Club home page Giter Club logo

ns-v8ios-runtime's Introduction

Getting Started

To start diving into the v8 iOS runtime make sure you have XCode and Homebrew installed, and then run the following

# Install CMake
brew install cmake

# Clone repo
git clone https://github.com/NativeScript/ns-v8ios-runtime.git

# Initialize and clone the submodules
cd ns-v8ios-runtime
git submodule update --init

# Open the runtime in XCode
open v8ios.xcodeproj

Select the TestRunner target and an emulator and hit Run (the play button).

Screenshot 2020-09-09 at 18 25 43

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.

Attaching the runtime to a NativeScript app

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.

Screenshot 2020-09-09 at 18 46 18

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:

Screenshot 2020-09-09 at 18 47 23

Add the Nativescript.framework from the v8ios workspace (only required when running on a physical device):

Screen Shot 2021-04-12 at 11 49 10 AM

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.

Overview

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

Building V8

In order to build the V8 engine for iOS and produce the static libraries used in this project follow those steps:

  1. Get depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=`pwd`/depot_tools:"$PATH"
  1. fetch v8 (this will create a v8 repo folder automatically checking out the master branch)

  2. cd v8; gclient sync (this will fetch additional dependencies for building the latest revision)

Ensure you navigate back to root of project: cd ..

  1. Apply patches: apply_patch.sh

  2. Run build_v8.sh

The compiled fat static libraries will be placed inside the v8/dist folder.

Building a Distribution Package

Use the build_all.sh script included in this repository to produce the dist/npm/nativescript-ios-{version}.tgz NPM package.

ns-v8ios-runtime's People

Contributors

darind avatar nathanwalker avatar nathanaela avatar rigor789 avatar logikgate avatar burgov avatar tdermendjiev avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.