text
stringlengths
1
372
macOS-specific support
section below to understand how entitlements,
the app sandbox, and the hardened runtime
impact your distributable application.
build and release a macOS app provides a more detailed
step-by-step walkthrough of releasing a flutter app to the
app store.
<topic_end>
<topic_start>
entitlements and the app sandbox
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:
then you must set up specific entitlements in xcode.
the following section tells you how to do this.
<topic_end>
<topic_start>
setting up entitlements
managing sandbox settings is done in the
macos/Runner/*.entitlements files. when editing
these files, you shouldn’t remove the original
Runner-DebugProfile.entitlements exceptions
(that support incoming network connections and JIT),
as they’re necessary for the debug and profile
modes to function correctly.
if you’re used to managing entitlement files through
the xcode capabilities UI, be aware that the capabilities
editor updates only one of the two files or,
in some cases, it creates a whole new entitlements
file and switches the project to use it for all configurations.
either scenario causes issues. we recommend that you
edit the files directly. unless you have a very specific
reason, you should always make identical changes to both files.
if you keep the app sandbox enabled (which is required if you
plan to distribute your application in the app store),
you need to manage entitlements for your application
when you add certain plugins or other native functionality.
for instance, using the file_chooser plugin
requires adding either the
com.apple.security.files.user-selected.read-only or
com.apple.security.files.user-selected.read-write entitlement.
another common entitlement is
com.apple.security.network.client,
which you must add if you make any network requests.
without the com.apple.security.network.client entitlement,
for example, network requests fail with a message such as:
important: the com.apple.security.network.server
entitlement, which allows incoming network connections,
is enabled by default only for debug and profile
builds to enable communications between flutter tools
and a running app. if you need to allow incoming
network requests in your application,
you must add the com.apple.security.network.server
entitlement to Runner-Release.entitlements as well,
otherwise your application will work correctly for debug or
profile testing, but will fail with release builds.
for more information on these topics,
see app sandbox and entitlements
on the apple developer site.
<topic_end>
<topic_start>
hardened runtime
if you choose to distribute your application outside
of the app store, you need to notarize your application
for compatibility with macOS 10.15+.
this requires enabling the hardened runtime option.
once you have enabled it, you need a valid signing
certificate in order to build.
by default, the entitlements file allows JIT for
debug builds but, as with app sandbox, you might
need to manage other entitlements.
if you have both app sandbox and hardened
runtime enabled, you might need to add multiple
entitlements for the same resource.
for instance, microphone access would require both
com.apple.security.device.audio-input (for hardened runtime)
and com.apple.security.device.microphone (for app sandbox).
for more information on this topic,
see hardened runtime on the apple developer site.
<topic_end>
<topic_start>
binding to native macOS code using dart:ffi
flutter mobile and desktop apps can use the
dart:ffi library to call native c APIs.
FFI stands for foreign function interface.
other terms for similar functionality include
native interface and language bindings.
info note
this page describes using the dart:ffi library
in macOS desktop apps.
for information on android, see
binding to native android code using dart:ffi.
for information on iOS, see
binding to native iOS code using dart:ffi.
this feature is not yet supported for web plugins.
before your library or program can use the FFI library
to bind to native code, you must ensure that the
native code is loaded and its symbols are visible to dart.