Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to publish Electron app to the app store?

I've packaged the app to mas file for uploading to the App Store. But

  1. From Xcode 11, they don't provide an application loader anymore.
  2. The Electron doesn't generate the XCode project.

In this case, what will be the best solution?

like image 387
tpikachu Avatar asked Aug 02 '20 13:08

tpikachu


1 Answers

1. We need to generate certificates on developer.apple.com and also need to import into our keychain.

  • Apple Development Certificates
  • Apple Distribution Certificates
  • Mac App Distribution Certificates (For Notarization)
  • Mac Installer Distribution Certificates (For Notarization)
  • (3rd Party) Developer ID Application Certificates (For publishing to App store)
  • (3rd Party) Developer ID Installer Certificates (For publishing to App store)

enter image description here

And then you need to download your app's provision profile from the app store connect. (Place this wherever you wanna be but need to indicate this in configuration)

You can find create and download the app's provision profile here https://developer.apple.com/account/resources/profiles/list

2. Need to configure your electron-builder. Here is the configuration.

{
    "productName": "your product",
    "appId": "com.my.first.app", //which can be found on your app store connect
    "directories": {
        "buildResources": "buildResources",
        "output": "release"
    },
    "files": ["main.js", "node_modules", "build" ], // include other necessary resources.
    "mac": {
        "type": "distribution",
        "target": ["mas", "pkg", "dmg"],
        "artifactName": "${productName}-${version}-${os}.${ext}",
        "category": "public.app-category.utilities",
        "provisioningProfile": "embedded.provisionprofile"
    },
    "mas": {
        "hardenedRuntime" : false, //IMPORTANT!!!!
        "type": "distribution",
        "category": "public.app-category.utilities",
        "entitlements": "build/entitlements.mas.plist",
        "entitlementsInherit": "build/entitlements.mas.inherit.plist"
    },
}

build/entitlements.mas.plist

<?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.app-sandbox</key>
        <true/>
        <key>com.apple.security.application-groups</key>
        <string>[prefix (on your app store connect)].[app bundleID EX: com.desktop.app]</string>
        <key>com.apple.security.cs.allow-jit</key>
        <true/>
        <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
        <true/>
        <key>com.apple.security.cs.allow-dyld-environment-variables</key>
        <true/>
    </dict>
</plist>

build/entitlements.mas.inherit.plist

<?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.app-sandbox</key>
        <true/>
        <key>com.apple.security.inherit</key>
        <true/>
    </dict>
</plist>

(as this entitlements list are the basic one and you can configure as your needs, but the above one is mandatory for publishing the app store. Especially, sand-box must be set as Apple's requirement)

After run npm run build which means (electron-builder .) Electron-builder will generate the mas, mac, pkg and then

3. To upload the app to the Mac App Store. I've used Transporter which is available on the Mac App Store. (As I mentioned before on question. From Xcode11 they don't support application loader anymore)

IMPORTANT: Electron-builder has fixed the signing issue from v22.5.0 So you need to use later version.

Finally here is the project structure that is working well with the current electron-builder. enter image description here

REFERENCE:

https://medium.com/@jondot/shipping-electron-apps-to-mac-app-store-with-electron-builder-e960d46148ec

https://github.com/electron/electron-osx-sign/issues/188

https://github.com/electron/electron/issues/22656

Hope this helps you so much~

(Unfortunately: when the sandbox is enabled app is stopped working. The Electron team is working on this task. So believe this will be resolved soon. https://github.com/electron/electron/issues/24936)

like image 74
tpikachu Avatar answered Oct 26 '22 16:10

tpikachu