Flutter MacOS App sandbox issue

387 views
Skip to first unread message

Thomas Verbeek

unread,
Oct 2, 2019, 6:47:04 AM10/2/19
to Flutter Development (flutter-dev)
I have written a Flutter desktop app for macOS. It uses a plugin to access Apple's Contacts framework to be able to offer the user's address book entries to the app.

When running with "flutter run -d macOS" the App does ask whether "Terminal" shall be allowed to access the address book. Afterwards the app has access to the user's address book. All good.

But when running the app by double clicking the compiled application bundle from the build directory (build/macos/Build/Products/Release/) the App does NOT ask for permission to access the address book!
In the macOS console app the following appears:

"Contacts TCC acccess preflight was denied" - subsystem: com.apple.contacts


The app is signed, sandboxed and the correct entitlements have been given (otherwise it would not work when running from the Terminal)

Why is the app not even asking the user for permission to access the address book?


I am running macOS Mojave 10.14.16.

I have already cleared all permission to the address book, but this does not help...


Stuart Morgan

unread,
Oct 2, 2019, 8:45:40 AM10/2/19
to Thomas Verbeek, Flutter Development (flutter-dev)
"flutter run" runs a debug build by default, while the file that you are double-clicking is a release build. Those configurations are covered by different entitlements files; did you add the necessary entitlements to both files as described at https://github.com/google/flutter-desktop-embedding/blob/master/macOS-Security.md?

-Stuart

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/b058cabc-8a3e-4c04-a579-73fffdf2391a%40googlegroups.com.
Message has been deleted

Thomas Verbeek

unread,
Oct 2, 2019, 11:06:53 AM10/2/19
to Flutter Development (flutter-dev)
OK, I found the solution: As i figured it was not a Flutter issue.
I simply forgot to put the following key into the info.plist of the runner:

<key>NSContactsUsageDescription</key>
<string>This app needs access to address book</string>

Once I did that, it works regardless of debug or release build and regardless how the app was started.

If anybody is interested in the flutter addressbook plugin, which currently supports macOS and iOS, you can find it here:


Am Mittwoch, 2. Oktober 2019 14:51:32 UTC+2 schrieb Thomas Verbeek:
Stuart,

thanks for answerding. Yes, i did enter the relevant entitlement in both debug and release files.
I also generated a release build by calling

flutter run —release -d macOS

The curious thing is that the difference does not come from debug or release builds but how the app is started:

1. Starting the app from Terminal it works:

porcupine:teambeam tom$ ./build/macos/Build/Products/Release/TeamBeam.app/Contents/MacOS/TeamBeam

2. Starting it by doeuble clicking the app icon in the build/macos/Build/Products/Release/ folder does not work!


Maybe this is not a Flutter but a macOS issue, but hopefully someone here has a hint for me.

Best regards,

Tom.

Reply all
Reply to author
Forward
0 new messages