realm-dart icon indicating copy to clipboard operation
realm-dart copied to clipboard

[Bug]: Realm SDK doesn't work by default on the MacOS emulator

Open mongodben opened this issue 1 year ago • 2 comments

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

  1. write code to log user in to Realm
  2. 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

mongodben avatar Sep 07 '22 19:09 mongodben

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.

nielsenko avatar Sep 07 '22 22:09 nielsenko

I think we should consider making a mason realm_starter brick. This could ask for permission to setup entitlements for the user.

nielsenko avatar Sep 07 '22 22:09 nielsenko

➤ Brian Munkholm commented:

Initially, document this.

sync-by-unito[bot] avatar Nov 01 '22 12:11 sync-by-unito[bot]