From 3b3a69895f0caa3870219bc0bec7420de81a07ed Mon Sep 17 00:00:00 2001 From: jebibot <83044352+jebibot@users.noreply.github.com> Date: Mon, 27 Nov 2023 16:15:50 +0900 Subject: [PATCH] fix: use product name for helper apps (#7900) Fixes #6962. --- .changeset/warm-pets-double.md | 5 +++++ packages/app-builder-lib/src/electron/electronMac.ts | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .changeset/warm-pets-double.md diff --git a/.changeset/warm-pets-double.md b/.changeset/warm-pets-double.md new file mode 100644 index 00000000000..10fd2b2ad6b --- /dev/null +++ b/.changeset/warm-pets-double.md @@ -0,0 +1,5 @@ +--- +"app-builder-lib": patch +--- + +fix macOS app with exectuableName different from productName diff --git a/packages/app-builder-lib/src/electron/electronMac.ts b/packages/app-builder-lib/src/electron/electronMac.ts index 9baba2bff56..cd0855f9f04 100644 --- a/packages/app-builder-lib/src/electron/electronMac.ts +++ b/packages/app-builder-lib/src/electron/electronMac.ts @@ -50,7 +50,10 @@ function getAvailableHelperSuffixes( /** @internal */ export async function createMacApp(packager: MacPackager, appOutDir: string, asarIntegrity: AsarIntegrity | null, isMas: boolean) { const appInfo = packager.appInfo - const appFilename = appInfo.productFilename + // Electon uses the application name (CFBundleName) to resolve helper apps + // https://github.com/electron/electron/blob/main/shell/app/electron_main_delegate_mac.mm + // https://github.com/electron-userland/electron-builder/issues/6962 + const appFilename = appInfo.sanitizedProductName const electronBranding = createBrandingOpts(packager.config) const contentsPath = path.join(appOutDir, packager.info.framework.distMacOsAppName, "Contents") @@ -270,7 +273,7 @@ export async function createMacApp(packager: MacPackager, appOutDir: string, asa await doRename(executableBasePath, `${prefix}${suffix}`, appFilename + suffix).then(() => doRename(loginItemPath, `${prefix}${suffix}.app`, `${appFilename}${suffix}.app`)) } - const appPath = path.join(appOutDir, `${appFilename}.app`) + const appPath = path.join(appOutDir, `${appInfo.productFilename}.app`) await rename(path.dirname(contentsPath), appPath) // https://github.com/electron-userland/electron-builder/issues/840 const now = Date.now() / 1000