electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.4k stars 505 forks source link

Can't add entitlements.plist #3521

Open Jaarson opened 6 months ago

Jaarson commented 6 months ago

Pre-flight checklist

Electron Forge version

7.2.0

Electron version

28.2.2

Operating system

macOS 14.0

Last known working Electron Forge version

No response

Expected behavior

Code from Docs should work, by using provided entitlements:

module.exports = {
  // ...
  packagerConfig: {
    // ...
    osxSign: {
      optionsForFile: (filePath) => {
        // Here, we keep it simple and return a single entitlements.plist file.
        // You can use this callback to map different sets of entitlements
        // to specific files in your packaged app.
        return {
          entitlements: './entitlements.plist'
        };
      }
    }
  }
  // ...
};

Actual behavior

When running npm run make it fails with following error

An unhandled rejection has occurred inside Forge:
Error: Failed to codesign your application with code: 1

MyApp.app: code has no resources but signature indicates they must be present

After commenting out optionsForFile part, there are no errors

Steps to reproduce

Create entitlements.plist file in root directory of your project, with the content from default entitlements: https://github.com/electron/osx-sign/blob/main/entitlements/default.darwin.plist

Additional information

No response

NxRoot commented 5 months ago

Same problem here when trying to setup permissions for microphone, it just crashes after packaging.

Ive also tested this using an old project with older versions and it works fine. So it seems to be a problem with the new versions.

Waiting for a fix...

MarshallOfSound commented 5 months ago

The default entitlements file is only user for some things in the default configuration. The reference implementation of "default options for file" is here https://github.com/electron/osx-sign/blob/main/src/sign.ts#L96-L112 and you can see that various entitlements files are used for different paths. Removing that logic will cause issues similar to what this original post is about

NxRoot commented 5 months ago

Perhaps anyone can help me out with this, im trying to use the microphone input. But it seems that the .app executable itself doesnt have the same behaviour as the Unix executable.

.app Exec (MICROPHONE DOES NOT WORK AND DOES NOT REQUEST PERMISSION)

Unix Exec (MICROPHONE WORKS AND REQUESTS PERMISSION)

There's no way to make an app this way.

Help...