electron-builder: MAS com.apple.security.app-sandbox in entitlements crashes the application

  • Version: 22.4.1
  • Target: mas

Sandbox entitlement is crashing the mas build on startup. The application works fine if I do not include <key>com.apple.security.app-sandbox</key><true/>, but it is refused by Mac Store. I tried using both mac and mas plist.

I even tried a workaround proposed in [https://github.com/electron/electron-osx-sign/issues/192](this issue) to add to node_modules/app-builder-lib/templates/entitlements.mac.plist the sandbox entitlement. The app crashes.

Here is my build config:

 "build": {
    "productName": "xxxxx",
    "appId": "com.xxx.xx",
    "artifactName": "${productName} Setup-${version}.${ext}",
    "mac": {
      "entitlementsInherit": "build/entitlements.mac.plist",
      "category": "public.app-category.business",
      "extraResources": [
        {
          "from": "./preconfigMac",
          "to": "preconfig",
          "filter": [
            "*.sh"
          ]
        }
      ]
    },
    "directories": {
      "output": "release"
    },
    "files": [
      "dist/",
      "package.json"
    ],
    "protocols": {
      "name": "Test protocol",
      "role": "Viewer",
      "schemes": [
        "test"
      ]
    },
    "mas": {
      "type": "distribution",
      "provisioningProfile": "embedded.provisionprofile",
      "entitlements": "build/entitlements.mas.plist",
      "entitlementsInherit": "build/entitlements.mas.inherit.plist"
    },
    "afterSign": "scripts/notarize.js"
  },

I identified the problem by checking the entitlements of the output. It seems that when I add sandbox entitlement it completely messes up the xml.

Here is the output of codesign -d --entitlements :- Test.app when entitlements do not include sandbox:

Executable=xxxxxx
<?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.cs.allow-jit</key>
  <true/>
  <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
  <true/>
  <key>com.apple.security.cs.disable-library-validation</key>
  <true/>
</dict>
</plist>

That is exactly the xml that I have in my entitlements.mas.plist.

However, when I add the sandbox entitlement to mas.plist or to mas.inherit.plist, this is the output:

Executable=xxxxx
bplist00?
                _ com.apple.application-identifier_#com.apple.developer.team-identifier_com.apple.security.app-sandbox_%com.apple.security.application-groups_com.apple.security.cs.allow-jit_6com.apple.security.cs.allow-unsigned-executable-memory_0com.apple.security.cs.disable-library-validation_xxxxxx	?       	       :`???7U`acdef%  

As you can see the entitlements are completely messed up because of the sandbox. Seems that there is some issue in how the entitlements are created during the build.

Any suggestions of what might be wrong?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 11
  • Comments: 38 (9 by maintainers)

Most upvoted comments

One of the many critical issues solved by the great stale bot! 🥳

Of course it is relevant! Fucking slate bot!

сб, 11 июл. 2020 г., 17:04 stale[bot] notifications@github.com:

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/electron-userland/electron-builder/issues/4790#issuecomment-657077307, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAF6VB7C3KK5O6TUXY36HTTR3B5PBANCNFSM4LMJ4WXQ .

@mordom0404 how do you install the .provisionprofile? When I double click its just opens the file in xCode. Is there another step that I need todo?

@mordom0404如何安装 .provisionprofile?双击它只会在 xCode 中打开文件。我还需要执行其他步骤吗? 你解决了吗 我也在看这个问题 did you resolve it?

首先要先到Apple Developer网站中的设备页,添加你电脑的UUID和UDID,这点非常重要,必须两个都要添加进去(虽然网页提示只需要UUID)

然后到Profiles页每个应用创建两个provisionprofile,一个是MacOS App Development(用于开发),一个是App Store Connect(用于发布到商店)。创建Development时请记得勾选全部的设备。 其中Development描述文件需要双击一下在系统描述文件中安装(打开方式选择"描述文件安装器.app",当我右键查看打开方式时,Mac默认的就是描述文件安装器.app,我不知道你们为啥默认的是xcode)。distribution预设不需要安装,只要放到我们的electron应用根目录即可。

最后一步,前往xcode中,进入设置,点击Accounts,登录你的账号,点击右下角download Manual Profiles。每次在apple developer中新增provisioning profile都要到这里来点击一下这个按钮,否则你的Transporter将无法上传应用到Mac App Store

更详细的内容可以看看我写的这篇踩坑文章:https://www.jianshu.com/p/3f4765c319b6

First, go to the device page on the Apple Developer website and add your computer’s UUID and UDID. This is very important and you must add both (although the web page prompts that only the UUID is required).

Then go to the Profiles page and create two provisionprofiles for each application, one for MacOS App Development (for development) and one for App Store Connect (for publishing to the store). Please remember to check all devices when creating Development. The Development profile needs to be double-clicked to install in the system profile (you can try right click and select “Profile Installer.app” when opening it, When I right-click to view the open method, the default on Mac is the profile installer.app. I don’t know why your default is xcode.). The distribution preset does not need to be installed, just put it in the root directory of our electron application.

The last step is to go to Xcode, enter Settings, click Accounts, log in to your account, and click Download Manual Profiles in the lower right corner. Every time you add a provisioning profile in Apple Developer, you must click this button here, otherwise your Transporter will not be able to upload apps to the Mac App Store.

For more details, please see this article I wrote: https://www.jianshu.com/p/3f4765c319b6