iOS の相互コンパイル

このページは、iOS ターゲット向けに V8 をビルドするための簡単なイントロダクションとして用意しています。

要件 #

初期設定 #

V8 をビルドする手順に従ってください

libv8_monolith.a ソースディレクトリの親ディレクトリにある .gclient コンフィギュレーションファイルで target_os を追加することで、iOS の相互コンパイルに必要な追加ツールを取得します。

# [... other contents of .gclient such as the 'solutions' variable ...]
target_os = ['ios']

.gclient を更新した後、gclient sync を実行して追加ツールをダウンロードします。

手動ビルド #

このセクションでは、物理 iOS デバイスまたは Xcode iOS シミュレーターで使用する単一の V8 バージョンをビルドする方法を示します。このビルドの出力は、V8 ライブラリと V8 スナップショットのすべてを含む libv8_monolith.a ファイルです。

gn args out/release-ios を実行して GN ビルドファイルをセットアップし、次のキーを挿入します。

ios_deployment_target = 10
is_component_build = false
is_debug = false
target_cpu = "arm64" # "x64" for a simulator build.
target_os = "ios"
use_custom_libcxx = false # Use Xcode's libcxx.
v8_enable_i18n_support = false # Produces a smaller binary.
v8_monolithic = true # Enable the v8_monolith target.
v8_use_external_startup_data = false # The snaphot is included in the binary.
v8_enable_pointer_compression = false # Unsupported on iOS.

ビルドします。

ninja -C out/release-ios v8_monolith

最後に、生成された libv8_monolith.a ファイルを、スタティックライブラリとして Xcode プロジェクトに追加します。アプリケーションに V8 を埋め込む方法のドキュメントについては、V8 を埋め込み始めるを参照してください。