objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence
https://docs.objectbox.io/getting-started
Apache License 2.0
927 stars 115 forks source link

Error during opening of ObjectBox-Dart library on the macOS #535

Closed ksatalsin closed 10 months ago

ksatalsin commented 1 year ago

When attempting to initialize the ObjectBox-Dart library without specifying a folder, an error occurs with an "Operation not permitted" (code 1) message. This is happening with the sandbox = ON in the entitlement runner file. The step with groups was done as described https://swift.objectbox.io/advanced/macos

Steps to reproduce

  1. Add the ObjectBox-Dart library.
  2. Set sandbox mode to ON in the entitlements file by adding the following code:
<key>com.apple.security.app-sandbox</key>
<true/>
  1. Attempt to open the ObjectBox-Dart library without specifying a folder in the code, like this:

final store = await openStore();

Expected behavior

Should be able to proceed without exception, because I am able to read/write data in the same folder

Logs, stack traces

greenrobot-team commented 1 year ago

The docs you linked are for objectbox-swift. For Flutter you also need to pass the application group to Store, see the info box "For sandboxed macOS apps". (Note: it's also recommended to edit the entitlements files manually for Flutter apps.)

Edit: let me know if this does not fix your issue. Otherwise, this issue will automatically close in 2 weeks if there is no response.

ksatalsin commented 11 months ago

Hi @greenrobot-team, thanks for the reply, I tried settings for the release with sandbox on and still got the same result:

image

and in the app

image

Thanks

greenrobot-team commented 11 months ago

Quoting the docs:

Note: Pick a short group identifier; there's an internal limit in macOS that requires the complete string to be 19 characters or fewer.

github-actions[bot] commented 10 months ago

Without additional information, we are unfortunately not sure how to resolve this issue. Therefore this issue has been automatically closed. Feel free to comment with additional details and we can re-open this issue.

DzianisMatveyeu commented 10 months ago

Quoting the docs:

Note: Pick a short group identifier; there's an internal limit in macOS that requires the complete string to be 19 characters or fewer.

full string $(TeamIdentifierPrefix).$(PRODUCT_BUNDLE_IDENTIFIER)should be shorter or only the group id? If it first, shud I change my bundle id to shorter version? If I use $(TeamIdentifierPrefix)as the group id, I also get a black screen.

<key>com.apple.security.application-groups</key>
<array>
<string>$(TeamIdentifierPrefix)</string>
greenrobot-team commented 10 months ago

@DzianisMatveyeu The 19 character limit is for the whole string passed to openStore(macosApplicationGroup: 'FGDTDLOBXDJ.demo'). E.g. in this example FGDTDLOBXDJ.demo.