text
stringlengths
1
372
the WidgetKit framework can trigger an update
of your home screen widget.
to simplify how your app communicates with extensions,
flutter plugins wrap these APIs.
to find plugins that wrap extension APIs,
check out leveraging apple’s system APIs and frameworks
or search pub.dev.
<topic_end>
<topic_start>
sharing resources
to share resources between your flutter app
and your app extension, put the runner app target
and the extension target in the same app group.
info note
you must be signed in to your apple developer account.
to add a target to an app group:
choose which app group you want to add the target from
one of two options:
when two targets belong to the same app group,
they can read from and write to the same source.
choose one of the following sources for your data.
<topic_end>
<topic_start>
background updates
background tasks provide a means to update your extension
through code regardless of the status of your app.
to schedule background work from your flutter app,
use the workmanager plugin.
<topic_end>
<topic_start>
deep linking
you might want to direct users from an
app extension to a specific page in your flutter app.
to open a specific route in your app,
you can use deep linking.
<topic_end>
<topic_start>
creating app extension UIs with flutter
some app extensions display a user interface.
for example, share extensions allow users to conveniently
share content with other apps,
such as sharing a picture to create
a new post on a social media app.
as of the 3.16 release, you can build
flutter UI for an app extension,
though you must use an extension-safe
flutter.xcframework and embed the
FlutterViewController as described in
the following section.
info note
due to the memory limitations of app extensions,
use flutter to build an app extension UI for extension
types that have memory limits larger than 100mb.
for example, share extensions have a 120mb memory limit.
in addition, flutter uses extra memory in debug mode.
therefore, flutter doesn’t fully support running
app extensions in debug mode on physical devices
when used to build extension UI; it might run out of memory.
as an alternative,
use an iOS simulator to test your extension in debug mode.
locate the extension-safe flutter.xcframework file,
at <path_to_flutter_sdk>/bin/cache/artifacts/engine/ios/extension_safe/flutter.xcframework.
drag and drop the flutter.xcframework file into your
share extension’s frameworks and libraries list.
make sure the embed column says “embed & sign”.
open the flutter app project settings in xcode
to share build configurations.
(optional) replace any storyboard files with an extension class, if needed.
embed the FlutterViewController as described in
adding a flutter screen. for example, you can display a
specific route in your flutter app within a share extension.
<topic_end>
<topic_start>
test extensions
testing extensions on simulators and physical devices
have slightly different procedures.
<topic_end>
<topic_start>
test on a simulator
<topic_end>
<topic_start>
test on a physical device
you can use the following procedure or the
testing on simulators instructions
to test on physical devices.
<topic_end>
<topic_start>
tutorials
for step-by-step instruction for using app
extensions with your flutter iOS app, check out the
adding a home screen widget to your flutter app
codelab.
<topic_end>
<topic_start>
binding to native iOS 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.