title | short-title | description |
---|---|---|
Debug your add-to-app module |
Debugging |
How to run, debug, and hot reload your add-to-app Flutter module. |
Once you've integrated the Flutter module to your project and used Flutter's platform APIs to run the Flutter engine and/or UI, you can then build and run your Android or iOS app the same way you run normal Android or iOS apps.
Flutter now powers the UI wherever your code includes
FlutterActivity
or FlutterViewController
.
You might be used to having your suite of favorite Flutter debugging tools
available when running flutter run
or an equivalent command from an IDE.
But you can also use all your Flutter debugging functionalities such as
hot reload, performance overlays, DevTools, and setting breakpoints in
add-to-app scenarios.
The flutter attach
command provides these functionalities.
To run this command, you can use the SDK's CLI tools, VS Code
or IntelliJ IDEA or Android Studio.
The flutter attach
command connects once you run your FlutterEngine
.
It remains attached until you dispose your FlutterEngine
.
You can invoke flutter attach
before starting your engine.
The flutter attach
command waits for the next available Dart VM that
your engine hosts.
To attach from the terminal, run flutter attach
.
To select a specific target device, add -d <deviceId>
.
$ flutter attach
The command should print output resembling the following:
Syncing files to device iPhone 15 Pro...
7,738ms (!)
To hot reload the changes while running, press "r".
To hot restart (and rebuild state). press "R".
An Observatory debugger and profiler on iPhone 15 Pro is available at:
http://127.0.0.1:65525/EXmCgco5zjo=/
For a more detailed help message, press "h".
To detach, press "d"; to quit, press "q".
{% include docs/debug/debug-flow-ios.md add='launch' %}
{% include docs/debug/debug-flow-androidstudio-as-start.md %}
To debug your app over Wi-Fi on an iOS or Android device,
use flutter attach
.
For an iOS target, complete the follow steps:
-
Verify your device connects to Xcode over Wi-Fi as described in the iOS setup guide.
-
On your macOS development machine, open Xcode > Product > Scheme > Edit Scheme....
You can also press Cmd + <.
-
Click Run.
-
Click Arguments.
-
In Arguments Passed On Launch, Click +.
{:type="a"}
-
If your dev machine uses IPv4, add
--vm-service-host=0.0.0.0
. -
If your dev machine uses IPv6, add
--vm-service-host=::0
.
{% render docs/app-figure.md, img-class:"site-mobile-screenshot border", image:"development/add-to-app/debugging/wireless-port.png", caption:"Arguments Passed On Launch with an IPv4 network added", width:"100%" %}
-
-
Open Settings > Wi-Fi.
-
Click on your connected network.
-
Click Details...
-
Click TCP/IP.
-
Check for an IPv6 address section.
{% render docs/app-figure.md, img-class:"site-mobile-screenshot border", image:"development/add-to-app/ipv6.png", caption:"WiFi dialog box for macOS System Settings", width:"60%" %}
Verify your device connects to Android Studio over Wi-Fi as described in the Android setup guide.