refractor: add missing MacOS depencies for tauri application

This commit is contained in:
2026-03-25 07:11:37 +01:00
parent b4b3494e17
commit 778a3fc258
7 changed files with 66 additions and 13 deletions

View File

@@ -10,6 +10,9 @@
"tauri:build": "tauri build", "tauri:build": "tauri build",
"helper:windows-x64": "bash ./scripts/build-tunnel-helper.sh x86_64-pc-windows-msvc", "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-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" "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": { "dependencies": {

View File

@@ -21,6 +21,10 @@ case "${TARGET}" in
OUTPUT_DIR="${BUNDLED_DIR}/macos-arm64" OUTPUT_DIR="${BUNDLED_DIR}/macos-arm64"
OUTPUT_NAME="nexavpn-tunnel-helper" OUTPUT_NAME="nexavpn-tunnel-helper"
;; ;;
x86_64-apple-darwin)
OUTPUT_DIR="${BUNDLED_DIR}/macos-x64"
OUTPUT_NAME="nexavpn-tunnel-helper"
;;
*) *)
echo "unsupported target: ${TARGET}" echo "unsupported target: ${TARGET}"
exit 1 exit 1
@@ -49,12 +53,14 @@ if [ "${TARGET}" = "x86_64-pc-windows-msvc" ]; then
esac esac
fi fi
if [ "${TARGET}" = "aarch64-apple-darwin" ] && [ "${HOST_OS}" != "Darwin" ]; then if [ "${TARGET}" = "aarch64-apple-darwin" ] || [ "${TARGET}" = "x86_64-apple-darwin" ]; then
echo "macOS ARM helper builds must run on macOS." if [ "${HOST_OS}" != "Darwin" ]; then
echo "Current host: ${HOST_OS}" echo "macOS helper builds must run on macOS."
echo "Use a Mac, then install the target with:" echo "Current host: ${HOST_OS}"
echo " rustup target add aarch64-apple-darwin" echo "Use a Mac, then install the target with:"
exit 1 echo " rustup target add ${TARGET}"
exit 1
fi
fi fi
if ! command -v rustup >/dev/null 2>&1; then 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" curl -fsSL "${MSI_URL}" -o "${OUTPUT_DIR}/wireguard-installer.msi"
fi 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_BIN="$(command -v wg || true)"
WG_QUICK_BIN="$(command -v wg-quick || true)" WG_QUICK_BIN="$(command -v wg-quick || true)"

View File

@@ -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.

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>

View File

@@ -996,8 +996,17 @@ pub fn run() {
Ok(()) Ok(())
}) })
.on_window_event(|window, event| match event { .on_window_event(|window, event| match event {
WindowEvent::CloseRequested { .. } => { WindowEvent::CloseRequested { api, .. } => {
window.app_handle().exit(0); #[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(_) => { WindowEvent::Resized(_) => {
if window.is_minimized().unwrap_or(false) { if window.is_minimized().unwrap_or(false) {

View File

@@ -15,8 +15,10 @@ const CREATE_NO_WINDOW: u32 = 0x08000000;
pub fn current_tunnel_strategy() -> &'static str { pub fn current_tunnel_strategy() -> &'static str {
if cfg!(target_os = "windows") { if cfg!(target_os = "windows") {
"embedded-wireguard-windows-x64" "embedded-wireguard-windows-x64"
} else if cfg!(target_os = "macos") { } else if cfg!(all(target_os = "macos", target_arch = "aarch64")) {
"embedded-wireguard-macos-arm" "embedded-wireguard-macos-arm64"
} else if cfg!(all(target_os = "macos", target_arch = "x86_64")) {
"embedded-wireguard-macos-x64"
} else { } else {
"unsupported" "unsupported"
} }
@@ -108,10 +110,12 @@ fn bundled_backend(app: &AppHandle) -> Result<PathBuf, String> {
let relative = if cfg!(target_os = "windows") { let relative = if cfg!(target_os = "windows") {
PathBuf::from("bundled/windows-x64/nexavpn-tunnel-helper.exe") 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") 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 { } 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); let path = resource_dir.join(relative);

View File

@@ -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"
}
}
}