电子/类星体-在签名和沙箱之后如何运行Mac应用程序?

时间:2018-10-30 13:34:28

标签: macos electron mac-app-store appstore-sandbox quasar-framework

我有一个Quasar / Electron Mac应用程序,允许用户单击一个代码段并将其粘贴到上次查看的应用程序(例如Mail等)中。

当我为mas(Mac App Store)平台构建应用程序时没有进行签名和沙箱测试,并且在 quasar.conf.js 中设置了以下设置

electron: {
    packager: {
        asar: false,
        appBundleId: '[app id]',
        platform: 'mas', 
        version: '1.0.0',
        buildVersion: '4'
    }
}

...以及以下构建命令:

quasar build -m electron

然后双击生成的应用程序文件即可正常运行。

但是,如果我在应用程序中签名并对其进行沙箱测试,请在 quasar.conf.js 中使用以下设置:

electron: {
    packager: {
        asar: false,
        appBundleId: '[app id]',
        osxSign: {
            'entitlements': 'src-electron/default.entitlements.mas.plist'
        },
        platform: 'mas', 
        version: '1.0.0',
        buildVersion: '4'
    }
}

...带有以下 default.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.network.client</key>
        <true/>
    </dict>
</plist>

...和相同的构建命令:

quasar build -m electron

然后,当我双击生成的应用程序文件时,它立即退出并显示以下消息:

enter image description here

编辑:点击报告会显示以下消息:

PROCESS:               Email Snippets [90262]
Path:                  /Applications/MAMP/*/Email Snippets.app/Contents/MacOS/Email Snippets
Identifier:            com.dannyconnell.emailsnippets
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Email Snippets [90262]
User ID:               501

Date/Time:             2018-11-03 21:14:01.171 +0000
OS Version:            Mac OS X 10.13.6 (17G65)
Report Version:        12
Anonymous UUID:        E00B5535-E6DC-B81E-1DCC-43B629EDC468

Sleep/Wake UUID:       B3B79D2B-F30B-47B0-A980-0822EFC30745

Time Awake Since Boot: 90000 seconds
Time Since Wake:       480 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_CRASH (Code Signature Invalid)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace CODESIGNING, Code 0x1

kernel messages:

VM Regions Near 0 (cr2):
--> 
    __TEXT                 0000000103992000-0000000103993000 [    4K] r-x/rwx SM=COW  

Thread 0 Crashed:
0   ???                             0x000000011127d19c _dyld_start + 0

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x0000000000000000  rcx: 0x0000000000000000  rdx: 0x0000000000000000
  rdi: 0x0000000000000000  rsi: 0x0000000000000000  rbp: 0x0000000000000000  rsp: 0x00007ffeec26db20
   r8: 0x0000000000000000   r9: 0x0000000000000000  r10: 0x0000000000000000  r11: 0x0000000000000000
  r12: 0x0000000000000000  r13: 0x0000000000000000  r14: 0x0000000000000000  r15: 0x0000000000000000
  rip: 0x000000011127d19c  rfl: 0x0000000000000200  cr2: 0x0000000000000000

Logical CPU:     0
Error Code:      0x00000000
Trap Number:     0


Binary Images:
       0x103992000 -        0x103992ff7 +??? (0) <447A1052-3F46-3E1B-BAC8-64F49EDE036E> (null)
       0x11127c000 -        0x1112c6acf +??? (551.4) <8A72DE9C-A136-3506-AA02-4BA2B82DCAF3> (null)

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 58409
    thread_create: 0
    thread_set_state: 54

VM Region Summary:
ReadOnly portion of Libraries: Total=432K resident=0K(0%) swapped_out_or_unallocated=432K(100%)
Writable regions: Total=8404K written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=8404K(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
STACK GUARD                       56.0M        2 
Stack                             8192K        2 
__DATA                             228K        4 
__LINKEDIT                         128K        3 
__TEXT                             304K        3 
shared memory                        8K        3 
===========                     =======  ======= 
TOTAL                             64.7M       11 

Model: MacBookPro12,1, BootROM MBP121.0177.B00, 2 processors, Intel Core i5, 2.7 GHz, 8 GB, SMC 2.28f7
Graphics: Intel Iris Graphics 6100, Intel Iris Graphics 6100, Built-In
Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1867 MHz, 0x80AD, 0x483943434E4E4E424C54414C41522D4E5544
Memory Module: BANK 1/DIMM0, 4 GB, DDR3, 1867 MHz, 0x80AD, 0x483943434E4E4E424C54414C41522D4E5544
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x133), Broadcom BCM43xx 1.0 (7.77.37.31.1a9)
Bluetooth: Version 6.0.7f10, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
Serial ATA Device: APPLE SSD SM0256G, 251 GB
USB Device: USB 3.0 Bus
USB Device: Internal Memory Card Reader
USB Device: Bluetooth USB Host Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 27.1

如果我随后使用 electron-osx-flat 打包应用程序:

electron-osx-flat "dist/electron-mat/[app name]-mas-x64/[app name].app" --verbose

..并双击pkg文件将其安装,然后该应用程序将成功安装。但是,当我单击“应用程序”中的应用程序时,它再次立即退出,并显示上图中的消息。

编辑:另外,如果我在终端的.app文件中运行可执行文件,我只会收到以下消息:

Killed: 9

但是,当我将此生成的pkg文件提交进行审阅时,该应用程序基本上适用于审阅者,但是复制和粘贴功能不起作用。

我相信这与 default.entitlements.mas.plist 文件中缺少的权利有关。

但是,我希望能够在提交到应用商店之前亲自测试这些问题。

在对应用进行签名和沙箱处理后,如何运行和测试我的应用?

1 个答案:

答案 0 :(得分:1)

感谢 @miadz 为我指明正确的方向。

这是将您的Electron应用程序完全沙箱化的操作(这将在Apple Review团队中显示并应用所有权利):

1)首先,您需要一台用于测试应用程序的第二台Mac

2)将第二台Mac作为列出的设备添加到Apple Developer网站上(帐户> 证书,ID和配置文件> macOS > 设备> 所有)。您将需要Mac的UUID,可以从 Apple > 关于本机> 概述> 系统报告中的菜单栏中找到。 ..

3)在Apple Developer网站上为您的应用程序生成Mac Development Provisioning配置文件(帐户> 证书,ID和配置文件> macOS > 配置文件> 开发),并确保您选择第二台Mac作为设备。如果您已有开发配置文件,请对其进行编辑,然后在设备下选择第二台Mac。

4)下载您的配置文件并将其放在Quasar / Electron项目的根目录中

5)在开发Mac上,为 mas 平台(无需签名)构建应用,例如

electron: {
    packager: {
        asar: false,
        appBundleId: '[app id]',
        platform: 'mas', 
        version: '1.0.0',
        buildVersion: '4'
    }
}

然后...

quasar build -m electron

6)使用 electron-osx-sign (您可能需要首先npm install electron-osx-sign -g)对生成的应用进行签名以进行开发:

electron-osx-sign "dist/electron-mat/[app name]-mas-x64/[app name].app" --platform=mas --type=development --entitlements="src-electron/default.entitlements.mas.plist" --provisioning-profile="[app name]_Mac_Development.provisionprofile"

7)将生成的.app文件发送到第二台Mac并运行