Sqlite3 native dependency crashes on MAS build
See original GitHub issue- Version: 22.3.2
- Target: mas
This is my first Electron app so probably I am just missing a step or two to resolve this issue. Or maybe it’s a bug.
My electron app uses a SQLite database and requires the sqlite3 npm package. To work in the development environment it must be rebuilt into a binary file using electron-rebuild. This works fine in development. But when I build for the MAS using the required sandbox entitlement it crashes on launch. To isolate the issue I used the process on a Hello World app. I can build it for the MAS fine but if I install the sqlite3 dependency and require it (even without using the database) it crashes on launch. Below are the messages. I highlighted in yellow what seems to be significant.
Appears to be an issue with signing the sqlite3 native dependency if I follow it correctly. Says something about Library Validation and library load disallowed by system policy. Do I need to take some additional steps?
### Additional Information: • I have the relevant signing certificates installed: 3rd Party Mac Developer Application and 3rd Party Mac Developer Installer. • I’m not requesting any entitlements other than the required ones for sandboxing.
<key>com.apple.security.app-sandbox</key><true/>
<key>com.apple.security.application-groups</key>
<array>
<string>12345ABCDE.com.domainname.appname</string>
</array>
• I created a provision profile for the app using my 3rd Party Mac Developer Application certificate. It’s in a file at the project’s root directory called MacAppStore.provisionfile.
MAS build console logs During the MAS build for production, sqlite3 is rebuilt as a native dependency. Below are the console logs:
• electron-builder version=22.3.2 os=18.7.0
• loaded configuration file=package.json ("build" field)
• writing effective config file=dist/builder-effective-config.yaml
• rebuilding native dependencies dependencies=sqlite3@4.1.1 platform=darwin arch=x64
• packaging platform=mas arch=x64 electron=6.1.7 appOutDir=dist/mas
• signing file=dist/mas/AppName.app identityName=3rd Party Mac Developer Application: TeamName (12345ABCDE) identityHash=SOMELONGSTRING provisioningProfile=MacAppStore.provisionprofile
Some info from the Sqlite3 docs which may be relevant:
The sqlite3 module uses node-pre-gyp to download a pre-compiled binary for your platform, if it exists. Otherwise, it uses node-gyp to build the extension. It is also possible to make your own build of sqlite3 from its source instead of its npm package.
Relevant keys from the package.json file: I tried this with and without the postinstall script, and also tried setting buildDependenciesFromSource to true.
"dependencies": {
"sqlite3": "^4.1.1"
},
"devDependencies": {
"electron": "^6.1.7"
},
"scripts": {
"postinstall": "electron-builder install-app-deps"
},
"build": {
"appId": "com.domainname.appname",
"mac": {
"target": "mas",
"hardenedRuntime": false,
"gatekeeperAssess": false,
"entitlements": "build/entitlements.mas.plist",
"entitlementsInherit": "build/entitlements.mas.inherit.plist",
"provisioningProfile": "MacAppStore.provisionprofile",
"type": "distribution",
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (1 by maintainers)
Top GitHub Comments
Thanks, that works for distributing outside the Mac App Store if you also notarize the app and add hardened runtime entitlements of:
But to distribute the app through the Mac App Store the app needs to be sandboxed, meaning the app is self contained. For that you need to use the mas target and create a “provisioning profile” in your apple developer account.
@kzimny Are you intending to distribute your app on the mac app store? If so I’d be interested to know if you get the same errors I do.
And actually I found additional information since posting this issue. Adding:
to the package.json file under the “mac” key will allow the signed sqlite binary file to be read by Apple. So that solved the signing issue. But I’m still not out of the woods. I’m now getting a new error, also from sqlite3, that crashes the app on launch. I’ve queried the Apple Developers forum. We’ll see what they have to say. Another point is this issue affects all node dependencies, not just Sqlite3. I tried it with other node dependencies and they throw the same error. Seems all the trouble started with Catalina OS, as they threw a bunch of new roadblocks up.
same issue, do you have solution?