Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
On iOS 14 and later, enable the Dart multicast DNS service in the
**Debug** version of your iOS app.
This adds [debugging functionalities such as hot-reload and DevTools][]
using `flutter attach`.

:::warning
Never enable this service in the **Release** version of your app.
The Apple App Store might reject your app.
:::

To set local network privacy permissions only in the Debug version of your app,
create a separate `Info.plist` per build configuration.
SwiftUI projects start without an `Info.plist` file.
If you need to create a property list,
you can do so through Xcode or text editor.
The following instructions assume the default **Debug** and **Release**.
Adjust the names as needed depending on your app's build configurations.

1. Create a new property list.

1. Open your project in Xcode.

1. In the **Project Navigator**, click on the project name.

1. From the **Targets** list in the Editor pane, click on your app.

1. Click the **Info** tab.

1. Expand **Custom iOS Target Properties**.

1. Right-click on the list and select **Add Row**.

1. From the dropdown menu, select **Bonjour Services**.
This creates a new property list in the project directory
called `Info`. This displays as `Info.plist` in the Finder.

1. Rename the `Info.plist` to `Info-Debug.plist`

1. Click on **Info** file in the project list at the left.

1. In the **Identity and Type** panel at the right,
change the **Name** from `Info.plist` to `Info-Debug.plist`.

1. Create a Release property list.

1. In the **Project Navigator**, click on `Info-Debug.plist`.

1. Select **File** > **Duplicate...**.
You can also press <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>S</kbd>.

1. In the dialog box, set the **Save As:** field to
`Info-Release.plist` and click **Save**.

1. Add the necessary properties to the **Debug** property list.

1. In the **Project Navigator**, click on `Info-Debug.plist`.

1. Add the String value `_dartVmService._tcp`
to the **Bonjour Services** array.

1. _(Optional)_ To set your desired customized permission dialog text,
add the key **Privacy - Local Network Usage Description**.

<DashImage image="development/add-to-app/ios/project-setup/debug-plist.png" caption="The `Info-Debug` property list with the **Bonjour Services** and **Privacy - Local Network Usage Description** keys added" />

1. Set the target to use different property lists for different build modes.

1. In the **Project Navigator**, click on your project.

1. Click the **Build Settings** tab.

1. Click **All** and **Combined** sub-tabs.

1. In the Search box, type `plist`.
This limits the settings to those that include property lists.

1. Scroll through the list until you see **Packaging**.

1. Click on the **Info.plist File** setting.

1. Change the **Info.plist File** value
from `path/to/Info.plist` to `path/to/Info-$(CONFIGURATION).plist`.

<DashImage image="development/add-to-app/ios/project-setup/set-plist-build-setting.png" caption="Updating the `Info.plist` build setting to use build mode-specific property lists" />

This resolves to the path **Info-Debug.plist** in **Debug** and
**Info-Release.plist** in **Release**.

<DashImage image="development/add-to-app/ios/project-setup/plist-build-setting.png" caption="The updated **Info.plist File** build setting displaying the configuration variations" />

1. Remove the **Release** property list from the **Build Phases**.

1. In the **Project Navigator**, click on your project.

1. Click the **Build Phases** tab.

1. Expand **Copy Bundle Resources**.

1. If this list includes `Info-Release.plist`,
click on it and then click the **-** (minus sign) under it
to remove the property list from the resources list.

<DashImage image="development/add-to-app/ios/project-setup/copy-bundle.png" caption="The **Copy Bundle** build phase displaying the **Info-Release.plist** setting. Remove this setting." />

1. The first Flutter screen your Debug app loads prompts
for local network permission.

Click **OK**.

_(Optional)_ To grant permission before the app loads, enable
**Settings > Privacy > Local Network > Your App**.

[debugging functionalities such as hot-reload and DevTools]: /add-to-app/debugging
56 changes: 44 additions & 12 deletions sites/docs/src/content/add-to-app/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Add Flutter to an existing app
shortTitle: Add to app
description: Adding Flutter as a library to an existing Android or iOS app.
description: Adding Flutter as a library to an existing Android, iOS, macOS, or web app.
---

## Add-to-app
Expand All @@ -17,11 +17,11 @@ the rest can be rendered using existing technology. This method can also be used
to run shared non-UI logic by taking advantage of Dart's portability and
interoperability with other languages.

Add-to-app is currently supported on Android, iOS, and web.
Add-to-app is currently supported on Android, iOS, macOS, and web.

Flutter supports two flavors of add-to-app:

- **Multi-engine**: supported on Android and iOS, allows running one or more
- **Multi-engine**: supported on Android, iOS, and macOS, allows running one or more
instances of Flutter, each rendering a widget embedded into the host
application. Each instance is a separate Dart program, running in isolation
from other programs. Having multiple Flutter instances allows each instance to
Expand Down Expand Up @@ -72,10 +72,9 @@ various use-cases. Two of the most common use-cases are:

<DashImage figure image="development/add-to-app/ios-overview.webp" alt="Add-to-app steps on iOS" />

* Auto-build and import the Flutter module by adding a Flutter
SDK hook to your CocoaPods and to your Xcode build phase.
* Build your Flutter module into a generic [iOS Framework][]
* Build your Flutter module into a Swift package
for integration into your own build system.
* Auto-build and import the Flutter module using Xcode build phases.
* [`FlutterEngine`][ios-engine] API for starting and persisting
your Flutter environment independently of attaching a
[`FlutterViewController`][].
Expand All @@ -90,6 +89,20 @@ See our [add-to-app GitHub Samples repository][]
for sample projects in Android and iOS that import
a Flutter module for UI.

### Add to macOS applications
* Build your Flutter module into a Swift package
for integration into your own build system.
* Auto-build and import the Flutter module using Xcode build phases.
* [`FlutterEngine`][macos-engine] API for starting and persisting
your Flutter environment independently of attaching a
[`FlutterViewController`][macos-flutterviewcontroller].
* Swift host apps supported.
* Flutter modules can use [Flutter plugins][] to interact
with the platform.
* Support for Flutter debugging and stateful hot reload by
using `flutter attach` from IDEs or the command line to
connect to an app that contains Flutter.

### Add to web applications

Flutter can be added to any existing HTML DOM-based web app written in any
Expand Down Expand Up @@ -119,22 +132,30 @@ To add Flutter to an existing app, build it normally, then follow the
## Get started

To get started, see our project integration guide for
Android and iOS:
Android, web, iOS, and macOS:

<div class="card-grid">
<a class="card outlined-card" href="/add-to-app/android/project-setup">
<div class="card-header text-center">
<span class="card-title">Android</span>
</div>
</a>
<a class="card outlined-card" href="/platform-integration/web/embedding-flutter-web#embedded-mode">
<div class="card-header text-center">
<span class="card-title">Web</span>
</div>
</a>
</div>

<div class="card-grid">
<a class="card outlined-card" href="/add-to-app/ios/project-setup">
<div class="card-header text-center">
<span class="card-title">iOS</span>
</div>
</a>
<a class="card outlined-card" href="/platform-integration/web/embedding-flutter-web#embedded-mode">
<a class="card outlined-card" href="/add-to-app/macos/project-setup">
<div class="card-header text-center">
<span class="card-title">Web</span>
<span class="card-title">macOS</span>
</div>
</a>
</div>
Expand All @@ -150,14 +171,23 @@ see our API usage guides at the following links:
<span class="card-title">Android</span>
</div>
</a>
<a class="card outlined-card" href="/add-to-app/ios/add-flutter-screen">

<a class="card outlined-card" href="/platform-integration/web/embedding-flutter-web#manage-flutter-views-from-js">
<div class="card-header text-center">
<span class="card-title">web</span>
</div>
</a>
</div>

<div class="card-grid">
<a class="card outlined-card" href="/add-to-app/ios/add-flutter-screen">
<div class="card-header text-center">
<span class="card-title">iOS</span>
</div>
</a>
<a class="card outlined-card" href="/platform-integration/web/embedding-flutter-web#manage-flutter-views-from-js">
<a class="card outlined-card" href="/add-to-app/macos/add-flutter-screen">
<div class="card-header text-center">
<span class="card-title">Web</span>
<span class="card-title">macOS</span>
</div>
</a>
</div>
Expand Down Expand Up @@ -197,3 +227,5 @@ Web limitations:
[maintained by the Flutter team]: {{site.repo.packages}}/tree/main/packages
[multiple Flutters]: /add-to-app/multiple-flutters
[FlutterView]: https://api.flutter.dev/flutter/dart-ui/FlutterView-class.html
[macos-engine]: {{site.api}}/macos-embedder/interface_flutter_engine.html
[macos-flutterviewcontroller]: {{site.api}}/macos-embedder/interface_flutter_view_controller.html
Loading
Loading