realm-dart
realm-dart copied to clipboard
[Bug]: Realm SDK doesn't work by default on the MacOS emulator
What happened?
When using the Realm Flutter SDK on the MacOS emulator, network requests do not work unless i add the following code to the files DebugProfile.entitlements
and Release.entitlements
:
<key>com.apple.security.network.client</key>
<true/>
when i tried to log in a user without adding the above code, i got the following error message:
Realm Exception : non-zero custom status code considered fatal
potential fix ideas:
- realm flutter sdk can inject this code into these files on build (not sure if possible)
- more descriptive error message
- document that need to add this code
Repro steps
- write code to log user in to Realm
- open with mac emulator
Version
Flutter 3.0.5, Dart 2.17.6
What Realm SDK flavor are you using?
MongoDB Atlas (i.e. Sync, auth, functions)
What type of application is this?
Flutter Application
Client OS and version
macOS 12.5.1
Code snippets
this error was found when running the Realm Flutter template app https://github.com/mongodb-university/realm-template-apps/tree/main/flutter
Stacktrace of the exception/crash you're getting
Realm Exception : non-zero custom status code considered fatal
Relevant log output
none
That is a requirement for any sandboxed MacOS app using the network. We know that the error message:
Realm Exception : non-zero custom status code considered fatal
is vague, but I think it would be unconventional to set the entitlements automatically.
What may confuse you is that for Flutter:
macOS builds are configured by default to be signed, and sandboxed with App Sandbox. This means that if you want to confer specific capabilities or services on your macOS app, such as the following:
Accessing the internet Capturing movies and images from the built-in camera Accessing files Then you must set up specific entitlements in Xcode.
(https://docs.flutter.dev/development/platform-integration/macos/building#entitlements-and-the-app-sandbox)
You need your app to be sandboxed if you want to release it on the macos app store.
I think we should consider making a mason realm_starter brick. This could ask for permission to setup entitlements for the user.
➤ Brian Munkholm commented:
Initially, document this.