From 778a3fc258f75117f7e6c919fcc08ae1a446bdc4 Mon Sep 17 00:00:00 2001 From: nessi Date: Wed, 25 Mar 2026 07:11:37 +0100 Subject: [PATCH] refractor: add missing MacOS depencies for tauri application --- desktop-client/package.json | 3 +++ desktop-client/scripts/build-tunnel-helper.sh | 20 ++++++++++++------- .../src-tauri/bundled/macos-x64/README.txt | 6 ++++++ desktop-client/src-tauri/entitlements.plist | 10 ++++++++++ desktop-client/src-tauri/src/lib.rs | 13 ++++++++++-- .../src-tauri/src/tunnel_manager.rs | 12 +++++++---- .../src-tauri/tauri.macos.conf.json | 15 ++++++++++++++ 7 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 desktop-client/src-tauri/bundled/macos-x64/README.txt create mode 100644 desktop-client/src-tauri/entitlements.plist create mode 100644 desktop-client/src-tauri/tauri.macos.conf.json diff --git a/desktop-client/package.json b/desktop-client/package.json index 539f53b..bd0b55c 100644 --- a/desktop-client/package.json +++ b/desktop-client/package.json @@ -10,6 +10,9 @@ "tauri:build": "tauri build", "helper:windows-x64": "bash ./scripts/build-tunnel-helper.sh x86_64-pc-windows-msvc", "helper:macos-arm64": "bash ./scripts/build-tunnel-helper.sh aarch64-apple-darwin", + "helper:macos-x64": "bash ./scripts/build-tunnel-helper.sh x86_64-apple-darwin", + "tauri:build:macos-arm64": "tauri build --target aarch64-apple-darwin --config src-tauri/tauri.macos.conf.json", + "tauri:build:macos-x64": "tauri build --target x86_64-apple-darwin --config src-tauri/tauri.macos.conf.json", "tauri:build:windows-x64:linux": "chmod +x ./scripts/cargo-xwin ./scripts/clang-cl && PATH=\"$PWD/scripts:$PATH\" XWIN_ARCH=x86_64 tauri build --runner cargo-xwin --target x86_64-pc-windows-msvc --config src-tauri/tauri.windows.conf.json" }, "dependencies": { diff --git a/desktop-client/scripts/build-tunnel-helper.sh b/desktop-client/scripts/build-tunnel-helper.sh index ca15e3a..c3e51a8 100644 --- a/desktop-client/scripts/build-tunnel-helper.sh +++ b/desktop-client/scripts/build-tunnel-helper.sh @@ -21,6 +21,10 @@ case "${TARGET}" in OUTPUT_DIR="${BUNDLED_DIR}/macos-arm64" OUTPUT_NAME="nexavpn-tunnel-helper" ;; + x86_64-apple-darwin) + OUTPUT_DIR="${BUNDLED_DIR}/macos-x64" + OUTPUT_NAME="nexavpn-tunnel-helper" + ;; *) echo "unsupported target: ${TARGET}" exit 1 @@ -49,12 +53,14 @@ if [ "${TARGET}" = "x86_64-pc-windows-msvc" ]; then esac fi -if [ "${TARGET}" = "aarch64-apple-darwin" ] && [ "${HOST_OS}" != "Darwin" ]; then - echo "macOS ARM helper builds must run on macOS." - echo "Current host: ${HOST_OS}" - echo "Use a Mac, then install the target with:" - echo " rustup target add aarch64-apple-darwin" - exit 1 +if [ "${TARGET}" = "aarch64-apple-darwin" ] || [ "${TARGET}" = "x86_64-apple-darwin" ]; then + if [ "${HOST_OS}" != "Darwin" ]; then + echo "macOS helper builds must run on macOS." + echo "Current host: ${HOST_OS}" + echo "Use a Mac, then install the target with:" + echo " rustup target add ${TARGET}" + exit 1 + fi fi if ! command -v rustup >/dev/null 2>&1; then @@ -100,7 +106,7 @@ if [ "${TARGET}" = "x86_64-pc-windows-msvc" ]; then curl -fsSL "${MSI_URL}" -o "${OUTPUT_DIR}/wireguard-installer.msi" fi -if [ "${TARGET}" = "aarch64-apple-darwin" ]; then +if [ "${TARGET}" = "aarch64-apple-darwin" ] || [ "${TARGET}" = "x86_64-apple-darwin" ]; then WG_BIN="$(command -v wg || true)" WG_QUICK_BIN="$(command -v wg-quick || true)" diff --git a/desktop-client/src-tauri/bundled/macos-x64/README.txt b/desktop-client/src-tauri/bundled/macos-x64/README.txt new file mode 100644 index 0000000..3f5db9b --- /dev/null +++ b/desktop-client/src-tauri/bundled/macos-x64/README.txt @@ -0,0 +1,6 @@ +Bundle the macOS x64 NexaVPN tunnel helper here. + +Expected filename: +- nexavpn-tunnel-helper + +This helper encapsulates the WireGuard runtime so the end user only interacts with NexaVPN. diff --git a/desktop-client/src-tauri/entitlements.plist b/desktop-client/src-tauri/entitlements.plist new file mode 100644 index 0000000..5e2bb6f --- /dev/null +++ b/desktop-client/src-tauri/entitlements.plist @@ -0,0 +1,10 @@ + + + + + com.apple.security.network.client + + com.apple.security.network.server + + + diff --git a/desktop-client/src-tauri/src/lib.rs b/desktop-client/src-tauri/src/lib.rs index 0a0252f..621eea7 100644 --- a/desktop-client/src-tauri/src/lib.rs +++ b/desktop-client/src-tauri/src/lib.rs @@ -996,8 +996,17 @@ pub fn run() { Ok(()) }) .on_window_event(|window, event| match event { - WindowEvent::CloseRequested { .. } => { - window.app_handle().exit(0); + WindowEvent::CloseRequested { api, .. } => { + #[cfg(target_os = "macos")] + { + hide_main_window(window); + api.prevent_close(); + } + #[cfg(not(target_os = "macos"))] + { + let _ = api; + window.app_handle().exit(0); + } } WindowEvent::Resized(_) => { if window.is_minimized().unwrap_or(false) { diff --git a/desktop-client/src-tauri/src/tunnel_manager.rs b/desktop-client/src-tauri/src/tunnel_manager.rs index 79b3692..5f768b3 100644 --- a/desktop-client/src-tauri/src/tunnel_manager.rs +++ b/desktop-client/src-tauri/src/tunnel_manager.rs @@ -15,8 +15,10 @@ const CREATE_NO_WINDOW: u32 = 0x08000000; pub fn current_tunnel_strategy() -> &'static str { if cfg!(target_os = "windows") { "embedded-wireguard-windows-x64" - } else if cfg!(target_os = "macos") { - "embedded-wireguard-macos-arm" + } else if cfg!(all(target_os = "macos", target_arch = "aarch64")) { + "embedded-wireguard-macos-arm64" + } else if cfg!(all(target_os = "macos", target_arch = "x86_64")) { + "embedded-wireguard-macos-x64" } else { "unsupported" } @@ -108,10 +110,12 @@ fn bundled_backend(app: &AppHandle) -> Result { let relative = if cfg!(target_os = "windows") { PathBuf::from("bundled/windows-x64/nexavpn-tunnel-helper.exe") - } else if cfg!(target_os = "macos") { + } else if cfg!(all(target_os = "macos", target_arch = "aarch64")) { PathBuf::from("bundled/macos-arm64/nexavpn-tunnel-helper") + } else if cfg!(all(target_os = "macos", target_arch = "x86_64")) { + PathBuf::from("bundled/macos-x64/nexavpn-tunnel-helper") } else { - return Err("This NexaVPN client build supports embedded tunnel backends only for Windows x64 and macOS ARM".into()); + return Err("This NexaVPN client build supports embedded tunnel backends only for Windows x64, macOS ARM64, and macOS x64".into()); }; let path = resource_dir.join(relative); diff --git a/desktop-client/src-tauri/tauri.macos.conf.json b/desktop-client/src-tauri/tauri.macos.conf.json new file mode 100644 index 0000000..87fc0ce --- /dev/null +++ b/desktop-client/src-tauri/tauri.macos.conf.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://schema.tauri.app/config/2", + "bundle": { + "targets": ["dmg", "app"], + "icon": [ + "icons/icon.png", + "icons/icon.icns" + ], + "category": "Utility", + "macOS": { + "entitlements": "entitlements.plist", + "minimumSystemVersion": "11.0" + } + } +}