ビルド手順(macOS)
カスタムElectronバイナリを作成するために、macOS上で**Electron自体**をビルドする場合は、以下のガイドラインに従ってください。事前にビルドされたElectronバイナリを使用してアプリコードをバンドルおよび配布する場合は、アプリケーション配布ガイドを参照してください。
前提条件
- macOS >= 11.6.0
- Xcode。必要な正確なバージョンはビルドするブランチによって異なりますが、最新のXcodeバージョンは一般的に`main`ブランチをビルドするのに適しています。
- node.js(外部)
- Python >= 3.7
Arm64固有の前提条件
- Rosetta 2
- x64とarm64マシンの両方でクロスコンパイルする必要がある依存関係を使用する場合は、Rosettaのインストールをお勧めします。Rosettaは、softwareupdateコマンドラインツールを使用してインストールできます。
$ softwareupdate --install-rosetta
Electronのビルド
ビルド手順:GNを参照してください。
トラブルシューティング
Xcodeの「互換性のないアーキテクチャ」エラー(macOS arm64固有)
XcodeとXcodeコマンドラインツールの両方がインストールされている場合($ xcode -select --install
、または適切なバージョンを直接ダウンロードはこちら)、スタックトレースが以下のように表示される場合
xcrun: error: unable to load libxcrun
(dlopen(/Users/<user>/.electron_build_tools/third_party/Xcode/Xcode.app/Contents/Developer/usr/lib/libxcrun.dylib (http://xcode.app/Contents/Developer/usr/lib/libxcrun.dylib), 0x0005):
tried: '/Users/<user>/.electron_build_tools/third_party/Xcode/Xcode.app/Contents/Developer/usr/lib/libxcrun.dylib (http://xcode.app/Contents/Developer/usr/lib/libxcrun.dylib)'
(mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e))), '/Users/<user>/.electron_build_tools/third_party/Xcode/Xcode-11.1.0.app/Contents/Developer/usr/lib/libxcrun.dylib (http://xcode-11.1.0.app/Contents/Developer/usr/lib/libxcrun.dylib)' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))).`
arm64アーキテクチャを使用している場合、ビルドスクリプトが間違ったXcodeバージョン(11.x.yはarm64をサポートしていません)を指している可能性があります。/Users/
に移動し、Xcode-13.3.0.app
の名前をXcode.app
に変更して、正しいXcodeバージョンが使用されるようにします。
証明書の検証に失敗する
certifi
をインストールすると、次のエラーが修正されます。
________ running 'python3 src/tools/clang/scripts/update.py' in '/Users/<user>/electron'
Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac_arm64/clang-llvmorg-15-init-15652-g89a99ec9-1.tgz
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
Retrying in 5 s ...
Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac_arm64/clang-llvmorg-15-init-15652-g89a99ec9-1.tgz
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
Retrying in 10 s ...
Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Mac_arm64/clang-llvmorg-15-init-15652-g89a99ec9-1.tgz
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
Retrying in 20 s ...
この問題は、Python 3.6が廃止されたApple提供のOpenSSLライブラリの代わりに、独自のOpenSSLコピーを使用することに関係しています。certifi
は、デフォルトのルート証明書の厳選されたバンドルを追加します。この問題は、Electronリポジトリこちらで説明されています。この問題に関する詳細情報はこちらとこちらにあります。