-1

I would like to deploy a flutter app to all physical phones connected. My current solution is to deploy to each device one at a time, but I would like to do them all at once. The closest match I found from this answer is to use flutter run -d all with the --release flag in order to deploy to all devices.

However, using -d all attempts to deploy to emulators as well, which throws this error (and does not deploy to any of the devices):

Release mode is not supported by iPhone 8.

Output of flutter devices looks like this (with true ids removed):

PhysicalPixel (mobile)   • XXX1    • android-arm64  • Android 11 (API 30)
PhysicaliPhone (mobile)  • XXX2    • ios            • iOS 14.4.1
iPhone 8 (mobile)        • XXX3    • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
Chrome (web)             • chrome  • web-javascript • Google Chrome

Is there a way to "deploy all" only to physical devices? Desired result deploys to PhysicalPixel and PhysicaliPhone (etc. with more phones), but not to iPhone 8 (simulator) or Chrome.

Stephen C
  • 1,966
  • 1
  • 16
  • 30

1 Answers1

0

As far as I know, it isn't possible to order a to run on only physical devices by some form of argument, but you can specify which devices instead of -d all

If you combine the this answer (https://stackoverflow.com/a/59593575/13263384) from the same question you linked to, together wit a small alteration to the launch.json then it might be what you are after. So do something like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Physical-1",
            "request": "launch",
            "type": "dart",
            "deviceId": "XXX1",
            "args": [
                "--release"
            ]
        },
        {
            "name": "Physical-2",
            "request": "launch",
            "type": "dart",
            "deviceId": "XXX2",
            "args": [
                "--release"
            ]
        },
        "compounds": [
        {
            "name": "Physical devices",
            "configurations": [
                "Physical-1",
                "Physical-2"

            ]
        }
    ]
}

The compound name Physical devices will now be a runnable target which will launch the build to those devices.

Edit: Now that I read that answer more thouroughly, I think that answer is actually better than mine. But up to you how you want to do it!

Robert Sandberg
  • 6,832
  • 2
  • 12
  • 30
  • Does something like this work _without_ using VScode? I'm not using VScode -- just deploying from a terminal. – Stephen C Jun 08 '21 at 21:42
  • Ah okey. No, not that I'm aware of. In that case I'd try writing a simple start-script that does the manual labor of launching against one device at a time using -d. (I guess basically what VSCode does in the background) – Robert Sandberg Jun 09 '21 at 09:50