Closed jochendev closed 2 years ago
Thanks for bumping this to a standalone issue out of #166 - I'll repeat my last comment from there:
I was able to reproduce the macOS issue and indeed it tries to write to the right directory. I've made sure the directory exists so it was only supposed to create files but the issue was still the same. I suspect this has something to do with the app being sandboxed so objectbox-core doesn't have the right permissions to create the database properly. I'll discuss internally and I've noticed there're some docs about this for objectbox-swift: https://swift.objectbox.io/advanced/macos - not sure if any of that applies.
Thanks for bumping this to a standalone issue out of #166 - I'll repeat my last comment from there:
I was able to reproduce the macOS issue and indeed it tries to write to the right directory. I've made sure the directory exists so it was only supposed to create files but the issue was still the same. I suspect this has something to do with the app being sandboxed so objectbox-core doesn't have the right permissions to create the database properly. I'll discuss internally and I've noticed there're some docs about this for objectbox-swift: https://swift.objectbox.io/advanced/macos - not sure if any of that applies.
I followed the steps on the supplied link but still get the same error as original poster reported.
There's a macOS specific section in the Flutter Desktop docs: https://flutter.dev/desktop#macos-specific-support
Haven't tried yet, but seems like a different approach...
Thanks for that link, I've updated the following lines to FALSE in my DebugProfile.entitlements and Release.entitlements file:
<key>com.apple.security.app-sandbox</key> <false/>
It is now working.
<key>com.apple.security.app-sandbox</key> <false/>
However, that means you won't be able to distribute the app through app store, right?
I did the same thing and turned off app-sandbox temporary so I can continue working on my app but I will have to enable it when it's done. From what I understood it's a special security thing from Apple that doesn't allow you to write/read files outside of your app's container folder without the user's consent. But no matter the path I'm giving to ObjectBox it keeps throwing me this error while just creating a simple file at that same path works.
Yeah, I'm 99.9 % sure it's not about the path but some of the other native API calls that are being executed during store setup. We'll have to take app-sandboxing as a known limitation for now until we figure out what permissions to set up so that it works. And I'm pretty sure it will, since the same native code is used for objectbox-swift...
The com.apple.security.cs.disable-library-validation entitlement is a candidate for causing the error:
This security-hardening feature prevents a program from loading frameworks, plug-ins, or libraries unless they’re either signed by Apple or signed with the same Team ID as the main executable.
Not exactly sure what Flutter does with the ObjectBox lib; depending on that there may be a mismatch...
Maybe someone likes to try this entitlement and report back?
I just tried it, but I still get the exception.
<key>com.apple.security.app-sandbox</key> <false/>
problem solved
@sunilpandit2 For development this is fine. But to build a release app, you might want to set a macosApplicationGroup
as described in the Store docs.
Okay
Thank you for responding
On 22 Apr 2024, at 12:47 PM, Uwe - ObjectBox @.***> wrote:
@sunilpandit2 https://github.com/sunilpandit2 For development this is fine. But to build a release app, you might want to set a macosApplicationGroup as described in the Store docs https://pub.dev/documentation/objectbox/latest/objectbox/Store/Store.html.
— Reply to this email directly, view it on GitHub https://github.com/objectbox/objectbox-dart/issues/248#issuecomment-2068657229, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMNYFVWNBQLUIY4F7R3PPTDY6S2O3AVCNFSM45ELNLS2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBWHA3DKNZSGI4Q. You are receiving this because you were mentioned.
Running "flutter pub get" in untitled... 1,220ms Launching lib/main.dart on macOS in debug mode... Running pod install... 1,395ms Building macOS application...
001-10:23:16.4099 [ERROR] Storage error "Operation not permitted" (code 1) [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: ObjectBoxException: failed to create store: 10199 Could not open database environment; please check options and file system (1: Operation not permitted)
0 ObjectBoxNativeError.throwMapped (package:objectbox/src/native/bindings/helpers.dart:78:9)
1 throwLatestNativeError (package:objectbox/src/native/bindings/helpers.dart:50:48)
2 checkObxPtr (package:objectbox/src/native/bindings/helpers.dart:32:5)
3 new Store (package:objectbox/src/native/store.dart:105:7)
4 _MyHomePageState.initState. (package:untitled/main.dart:63:20)
5 _rootRunUnary (dart:async/zone.dart:1362:47)
6 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
7 _FutureListener.handleValue (dart:async/future_impl.dart:152:18)
8 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:704:45)
9 Future._propagateToListeners (dart:async/future_impl.dart:733:32)
10 Future._completeWithValue (dart:async/future_impl.dart:539:5)
11 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:254:13)
12 getTemporaryDirectory (package:path_provider/path_provider.dart)