Pre and Post Install Script in electron-fordge pkg maker Not working
Pre-flight checklist
- [X] I have read the contribution documentation for this project.
- [X] I agree to follow the code of conduct that this project uses.
- [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.
Electron Forge version
6.4
Electron version
26.6.10
Operating system
macOS 14 sonoma
Last known working Electron Forge version
6.4
Expected behavior
I've created an electron app and I'm packaging it using electron forge for Mac. I started creating .pkg files and I also created a shell script and added it to my packager config inside forge.config.js as follows
const config: ForgeConfig = {
packagerConfig: {
asar: true,
executableName: productName,
appCopyright: '.......',
icon: path.resolve(rootDir, 'assets/icons/romeano'),
osxSign: {},
osxNotarize: {
tool: 'notarytool',
appleId: envConfig.APPLE_ID,
appleIdPassword: envConfig.APPLE_PASSWORD,
teamId: envConfig.APPLE_TEAM_ID,
},
},
rebuildConfig: {},
makers: [
.....
new MakerPKG({
scripts: path.resolve(__dirname, 'Scripts'),
}),
],
plugins: [
new VitePlugin({
build: .....
renderer: ....
}),
],
};
export default config;
Inside my scripts folder I have my shell script as postinstall.sh The script works as expected when I run the file through terminal. But the script is not running after installation on the user's devices as expected of it.
Is there something I'm missing or doing wrong? Please help. I updated forge.config.js as mentioned on the electron-forge documentation but the scripts are still not running.
Actual behavior
The script shoould work when installing pkg
Additional information
My script is executable as well I run the chmod command to make it executable as mentioned here
No response
Faced the same issue. I have to manually build the pkg file using pkgbuild command to have my postinstall script working
@duchunter Can you share your approach. How I can solve this issue ?
Sure, after running electron-forge make with MakerPKG (or dmg), you'll get a folder containing the .app file, for example desktop-example-darwin-arm64/DesktopExample.app. Running sudo pkgbuild --root desktop-example-darwin-arm64 --install-location /Applications --scripts /path/to/your/Scripts testapp.pkg will create a new .pkg file. I guess it only solve the preinstall/postinstall problem, if you want to sign or notarize, maybe you have to do them manually as well.
@duchunter Thanks your approach works for me, But it it creating issue when I notarize this new .pkg
while notarize pkg it shows invalid status Waiting for processing to complete. Current status: Invalid...............
Here what I found in notary log
{ NSLocalizedDescription = "Failed to get notarization info."; NSLocalizedFailureReason = "You must specify authentication credentials (username/password or apiKey/apiIssuer)."; }
when I notarize initial pkg I specify all credentials. And if I notarize the initial pkg it successfully notarize but since we are creating new pkg it show status invalid
@arjunByldd01 Which notary tool did you use? Try this one:
xcrun notarytool submit <your-app.pkg> --apple-id <APPLE_ID> --password <APPLE_PASSWORD> --team-id <APPLE_TEAM_ID> --wait
Can't really help you beyond this point, since everytime I submit my app for notarization, they always response with:
"status": "Rejected",
"statusSummary": "Team is not yet configured for notarization. Please contact Developer Programs Support at developer.apple.com under the topic Development and Technical / Other Development or Technical Questions.",
"statusCode": 7000,
And after 12 months of contacting Developer Programs Support, their answer is still "We are still pending a response from our teams".
@duchunter Yes, I was using the same tool - xcrun notarytool submit.... and getting status as invalid only for the new pkg that we are creating. If I submit the initial pkg it shows status accepted.
Thanks for the support.
I think this will fix it upstream https://github.com/electron/osx-sign/pull/282
I’ve experienced the same situation as you and shared it on Twitter. Please follow and support us! Let’s fight for the rights we deserve! https://x.com/silent_orchid6/status/1954399957479567603