sudo apt-get install -y build-essential git python
sudo apt-get install -y curl unzip
Choose a location where you want to install the Android NDK and run:
curl https://dl.google.com/android/repository/android-ndk-r21b-linux-x86_64.zip -o ndk.zip
unzip ndk.zip
It will create a android-ndk-r21b
folder. Save that path for later.
Run git
in a terminal window, it will show a prompt to install it if not already present.
As an alternative, installing one of these will install git
:
Choose a location where you want to install the Android NDK and run:
curl https://dl.google.com/android/repository/android-ndk-r21b-darwin-x86_64.zip -o ndk.zip
unzip ndk.zip
It will create a android-ndk-r21b
folder. Save that path for later.
git clone https://github.com/janeasystems/nodejs-mobile
cd nodejs-mobile
git checkout mobile-master
The tools/android_build.sh
script takes as first argument the Android NDK path (in our case is ~/android-ndk-r21b
). The second argument must be the Android SDK version as a two-digit number. The third argument is the target architecture, which can be one of the following: arm
, x86
, arm64
or x86_64
. You can omit the third argument, and it will build all available architectures.
Run (example arguments):
./tools/android_build.sh ~/android-ndk-r21b 23
When done, each built shared library will be placed in out_android/$(ARCHITECTURE)/libnode.so
.
Run the android-configure
script to configure the build with the path to the downloaded NDK and the desired target architecture.
source ./android-configure ../android-ndk-r21b arm
Start the build phase:
make
This will create the Android armeabi-v7a
shared library in out/Release/lib.target/libnode.so
.
Install Xcode 11 or higher, from the App Store, and then install the Command Line Tools by running the following command:
xcode-select --install
That installs git
, as well.
To install CMake
, you can use a package installer like Homebrew.
First, install HomeBrew
, if you don't have it already.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then, use it to install CMake
:
brew install cmake
Add this to your Podfile
:
pod 'NodeMobile', :git => 'https://github.com/janeasystems/nodejs-mobile.git'
git clone https://github.com/nodejs-mobile/nodejs-mobile
cd nodejs-mobile
git checkout main
./tools/ios_framework_prepare.sh
That will configure gyp
to build Node.js and its dependencies as static libraries for iOS on the arm64 and x64 architectures, using the v8
engine configured to start with JIT disabled. The script copies those libraries to tools/ios-framework/bin/arm64
and tools/ios-framework/bin/x64
, respectively. It also merges them into static libraries that contain strips for both architectures, which will be placed in tools/ios-framework/bin
and used by the tools/ios-framework/NodeMobile.xcodeproj
Xcode project.
The helper script builds the tools/ios-framework/NodeMobile.xcodeproj
Xcode project into three frameworks:
- The framework to run on iOS devices:
out_ios/Release-iphoneos/NodeMobile.framework
- The framework to run on the iOS simulator:
out_ios/Release-iphonesimulator/NodeMobile.framework
- The universal framework, that runs on iOS devices and simulators:
out_ios/Release-universal/NodeMobile.framework