mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2025-01-08 13:41:59 -05:00
macOS: request camera and microphone access
Note `audio-input` and `camera` were already in `entitlements.plist` Supporting changes: - Add `allow-jit` entitlement since documentation says it's needed. - Only use sandbox for MAS build, not for non-MAS macOS build. NOTE: both still use the hardened runtime, as required on Catalina. - Remove `entitlements.inherit.plist` since it matches default settings. - Add to `electron-builder.yaml` English descriptions for why the app requests access to the microphone and camera. I'm not yet sure if there's a way to localize these. - Minor tweaks in `electron-builder.yaml`.
This commit is contained in:
parent
8222b715a7
commit
af73790306
6 changed files with 51 additions and 17 deletions
14
README.md
14
README.md
|
@ -79,6 +79,20 @@ To generate a signed NSIS installer:
|
|||
4. Build the NSIS installer only: building the APPX installer will fail if these environment variables are set.
|
||||
- `npm run dist -- -w nsis`
|
||||
|
||||
#### Workaround for code signing issue in macOS
|
||||
|
||||
Sometimes the macOS build process will result in a build which crashes on startup. If this happens, check in `Console`
|
||||
for an entry similar to this:
|
||||
|
||||
```text
|
||||
failed to parse entitlements for Scratch Desktop[12345]: OSUnserializeXML: syntax error near line 1
|
||||
```
|
||||
|
||||
This appears to be an issue with `codesign` itself. Rebooting your computer and trying to build again might help. Yes,
|
||||
really.
|
||||
|
||||
See this issue for more detail: <https://github.com/electron/electron-osx-sign/issues/218>
|
||||
|
||||
### Make a semi-packaged build
|
||||
|
||||
This will simulate a packaged build without actually packaging it: instead the files will be copied to a subdirectory
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?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.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
<key>com.apple.security.inherit</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -2,7 +2,7 @@
|
|||
<!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>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
22
buildResources/entitlements.mas.plist
Normal file
22
buildResources/entitlements.mas.plist
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?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.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
<key>com.apple.security.device.audio-input</key>
|
||||
<true/>
|
||||
<key>com.apple.security.device.camera</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-only</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -6,17 +6,23 @@ productName: "Scratch Desktop"
|
|||
afterSign: "scripts/afterSign.js"
|
||||
mac:
|
||||
category: public.app-category.education
|
||||
entitlements: buildResources/entitlements.mac.plist
|
||||
extendInfo:
|
||||
NSCameraUsageDescription: >-
|
||||
This app requires camera access when taking a photo in the paint editor or using the video sensing blocks.
|
||||
NSMicrophoneUsageDescription: >-
|
||||
This app requires microphone access when recording sounds or detecting loudness.
|
||||
gatekeeperAssess: true
|
||||
hardenedRuntime: true
|
||||
icon: buildResources/ScratchDesktop.icns
|
||||
provisioningProfile: embedded.provisionprofile
|
||||
target:
|
||||
- dmg
|
||||
- mas
|
||||
mas:
|
||||
type: distribution
|
||||
mas:
|
||||
category: public.app-category.education
|
||||
entitlements: buildResources/entitlements.plist
|
||||
entitlementsInherit: buildResources/entitlements.inherit.plist
|
||||
entitlements: buildResources/entitlements.mas.plist
|
||||
icon: buildResources/ScratchDesktop.icns
|
||||
win:
|
||||
icon: buildResources/ScratchDesktop.ico
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {BrowserWindow, Menu, app, dialog, ipcMain} from 'electron';
|
||||
import {BrowserWindow, Menu, app, dialog, ipcMain, systemPreferences} from 'electron';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {format as formatUrl} from 'url';
|
||||
|
@ -140,6 +140,10 @@ const createMainWindow = () => {
|
|||
if (process.platform === 'darwin') {
|
||||
const osxMenu = Menu.buildFromTemplate(MacOSMenu(app));
|
||||
Menu.setApplicationMenu(osxMenu);
|
||||
(async () => {
|
||||
await systemPreferences.askForMediaAccess('microphone');
|
||||
await systemPreferences.askForMediaAccess('camera');
|
||||
})();
|
||||
} else {
|
||||
// disable menu for other platforms
|
||||
Menu.setApplicationMenu(null);
|
||||
|
|
Loading…
Reference in a new issue