fix: app name contains spaces
fix #193
App Name: 900 TG
• Notarizing app: /path/to/dist/mac-arm64/900 TG.app ⨯ Failed to display codesign info on your application with code: 1
900 TG.app: No such process Failed to codesign your application with code: 1 900 TG.app: No such process 900 TG.app: No such process
This PR fixed this issue
@MarshallOfSound
This PR actually solves the fact that the spawn of the codesign MacOS utility has the correct fullpath to the packaged app.
The previous version would simply try to codesign the packaged app in the current working directory (which is wrong of course) because of wrong arguments passing.
Which causes official Electron boilerplates like (https://www.electronforge.io/templates/vite-+-typescript) to fail to pass the signing step when using yarn make.
When notarizing, using a relative path for the codesign parameter and an application name with spaces causes the notarization to fail. This issue does not occur with absolute paths.
For usage with https://www.npmjs.com/package/patch-package
Create file patches/@electron+notarize+2.3.2.patch with following content:
diff --git a/node_modules/@electron/notarize/lib/check-signature.js b/node_modules/@electron/notarize/lib/check-signature.js
index 324568a..c3d65f8 100644
--- a/node_modules/@electron/notarize/lib/check-signature.js
+++ b/node_modules/@electron/notarize/lib/check-signature.js
@@ -41,16 +41,14 @@ const spawn_1 = require("./spawn");
const debug_1 = __importDefault(require("debug"));
const d = (0, debug_1.default)('electron-notarize');
const codesignDisplay = (opts) => __awaiter(void 0, void 0, void 0, function* () {
- const result = yield (0, spawn_1.spawn)('codesign', ['-dv', '-vvvv', '--deep', path.basename(opts.appPath)], {
+ const result = yield (0, spawn_1.spawn)('codesign', ['-dv', '-vvvv', '--deep', opts.appPath], {
cwd: path.dirname(opts.appPath),
});
return result;
});
const codesign = (opts) => __awaiter(void 0, void 0, void 0, function* () {
d('attempting to check codesign of app:', opts.appPath);
- const result = yield (0, spawn_1.spawn)('codesign', ['-vvv', '--deep', '--strict', path.basename(opts.appPath)], {
- cwd: path.dirname(opts.appPath),
- });
+ const result = yield (0, spawn_1.spawn)('codesign', ['-vvv', '--deep', '--strict', opts.appPath]);
return result;
});
function checkSignatures(opts) {
I'm seeing this same error even without spaces.
# All of these run in the same folder with App-Name.app
# Does not work
codesign -vvv --deep --strict "App-Name.app"
codesign -vvv --deep --strict "App Name.app"
# Works
codesign -vvv --deep --strict "./App-Name.app"
codesign -vvv --deep --strict "./App Name.app"
codesign -vvv --deep --strict "/Users/<username>/src/app-name/out/mac-arm64/App-Name.app"
codesign -vvv --deep --strict "/Users/<username>/src/app-name/out/mac-arm64/App Name.app"
Since this was blocking me I ended up replacing @electron/notarize with a very simple (but no error handling for now) script. In my package.json I have:
"build": {
"mac": {
"notarize": false
},
"afterSign": "electron/notarize.js"
}
as normal. This is the same as if you are writing your own custom @electron/notarize script. My script however is just:
import { execSync } from "node:child_process";
async function notarizing(context) {
const { electronPlatformName, appOutDir } = context;
if (electronPlatformName !== "darwin") {
return;
}
if (!process.env.APPLEIDPASS) {
return;
}
const appName = context.packager.appInfo.productFilename;
const appPath = `${appOutDir}/${appName}.app`;
const zipPath = `${appOutDir}/${appName}.zip`;
const appleId = process.env.APPLE_ID;
const appleIdPassword = process.env.APPLEIDPASS;
const teamId = process.env.APPLE_TEAM_ID;
console.log(
execSync(`ditto -c -k --keepParent "${appPath}" "${zipPath}"`, {
encoding: "utf8",
}),
);
console.log(
execSync(
`xcrun notarytool submit "${zipPath}" --team-id "${teamId}" --apple-id "${appleId}" --password "${appleIdPassword}" --wait`,
{ encoding: "utf8" },
),
);
console.log(
execSync(`xcrun stapler staple "${appPath}"`, { encoding: "utf8" }),
);
}
export default notarizing;
Use as your own risk and make sure to check what environment variables you are using for CI/etc. This is working in my github actions and now my app is being packaged and notarizing again. Clearly the current logic used to run codesign with only the app bundle basename is not working. Until @electron/notarize updates to fix things I'll be using this.
# All of these run in the same folder with App-Name.app # Does not work codesign -vvv --deep --strict "App-Name.app" codesign -vvv --deep --strict "App Name.app" # Works codesign -vvv --deep --strict "./App-Name.app" codesign -vvv --deep --strict "./App Name.app" codesign -vvv --deep --strict "/Users/<username>/src/app-name/out/mac-arm64/App-Name.app" codesign -vvv --deep --strict "/Users/<username>/src/app-name/out/mac-arm64/App Name.app"
Do you mean the following?
# All of these run in the same folder with App-Name.app
# Does not work
codesign -vvv --deep --strict "App-Name.app"
codesign -vvv --deep --strict "App Name.app"
# Works
codesign -vvv --deep --strict "/Users/<username>/src/app-name/out/mac-arm64/App-Name.app"
codesign -vvv --deep --strict "/Users/<username>/src/app-name/out/mac-arm64/App Name.app"
@MarshallOfSound Mar Hi, Consider merging this PR. There shouldn't be any side effects. Since codesign is closed source, the specific reason is difficult to adjust. This may be a bug in codesign.