如何在 VSCode 中配置`flutter Attach --app-id com.example.id`?

问题描述 投票:0回答:2

我在做什么?

我有一个原生 iOS 应用程序,带有集成的 Flutter 添加到应用程序模块。为了调试 dart 代码,我在 iOS 模拟器中启动了本机应用程序,然后运行 flutter Attach 将 Flutter 调试器附加到本机应用程序。 下面是我的 launch.json 文件。

    "version": "0.2.0",
    "configurations": [
        {
            "name": "chope_app_flutter",
            "request": "launch",
            "type": "dart"
        },
        { 
            "name": "chope_app_flutter (iOS attach)",
            "request": "attach",
            "type": "dart"
        },
    ],
}

有什么问题吗?

有时,当我开始调试 flutter Attach 时,会出现一些错误。

There are multiple observatory ports available.
Rerun this command with one of the following passed in as the appId:

  flutter attach --app-id com.example.id
  flutter attach --app-id com.example.id (2)

我知道在终端中运行它是可以的,但我想在 VSCode 中调试 flutter 代码。

有人可以帮忙解决这个问题吗?

谢谢!

ios flutter vscode-debugger
2个回答
1
投票

我刚刚遇到了类似的问题并解决如下:

// launch.json
{
  // ...
  "configurations": [
    {
      "name": "chope_app_flutter",
      "request": "attach",
      "type": "dart",
      "args": ["--app-id", "com.example.id"]
    }
  ]
  // ...
}

假设第一个应用程序 ID 确实是您要附加的应用程序 ID。

有关 VSCode 的更多信息

launch.json
,请参阅 他们的文档


0
投票
{
            "name": "iPhone | ATTACH",
            "request": "attach",
            "type": "dart",
            "deviceId": "DEVICE ID",
            "vmServiceUri": "http://127.0.0.1:55513/PxmQR7Gid8I=/",//get it from Xcode for example after running your app
            // "program": "lib/main.dart",//change for flavors
            "args": [
                "-t lib/main.dart",
                "--app-id",
                "com.example.app",
                "--device-vmservice-port",
                "55513",
                "-d",
                "Device ID",
            ]
        },
    ]
}
© www.soinside.com 2019 - 2024. All rights reserved.