macos – Debug a MAUI App for iOS device on VS Code on MAC


I’m developing a bluetooth app on iOS using MAUI on a MAC with VS Code.

Following this walkthrough (https://egvijayanand.in/2021/04/04/net-maui-project-debug-with-vs-code/), I downloaded the extensions:

And parametized the tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "command": "dotnet",
            "type": "shell",
            "args": [
                "build",
                "${input:project}",
                "-t:${input:target}",
                "-f:${input:targetFramework}",
                "-c:${input:configuration}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "reveal": "always"
            },
            "problemMatcher": "$msCompile"
        },
        {
            "label": "Run",
            "command": "dotnet",
            "type": "shell",
            "args": [
                "build",
                "${input:project}",
                "-f:${input:targetFramework}",
                "-c:${input:configuration}",
                "-p:RuntimeIdentifier=ios-arm64",
                "-p:_DeviceName=00008030-000555CC21A3802E",
                "-t:Run",
                "--no-restore"
            ],
            "group": "build",
            "presentation": {
                "reveal": "always"
            },
            "problemMatcher": "$msCompile"
        }
    ],
    "inputs": [
        {
            "id": "project",
            "type": "pickString",
            "default": "MauiAppBLEClient/MauiAppBLEClient.csproj",
            "description": "Select the project to build / run",
            "options": [
                "MauiAppBLEClient/MauiAppBLEClient.csproj"
            ]
        },
        {
            "id": "configuration",
            "type": "pickString",
            "default": "Debug",
            "description": "Select MSBuild configuration",
            "options": [
                "Debug",
                "Release"
            ]
        },
        {
            "id": "target",
            "type": "pickString",
            "default": "Build",
            "description": "Select MSBuild target",
            "options": [
                "Build",
                "Rebuild",
                "Clean"
            ]
        },
        {
            "id": "targetFramework",
            "type": "pickString",
            "default": "net8.0-ios",
            "description": "Select target framework (TFM)",
            "options": [
                "net8.0-ios"
            ]
        },
        {
            "id": "attachDebugger",
            "type": "pickString",
            "default": "true",
            "description": "Attach debugger?",
            "options": [
                "true",
                "false"
            ]
        }
    ]
}

And launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to Mono",
            "request": "attach",
            "type": "mono",
            "address": "localhost",
            "port": 10000,
            "preLaunchTask": "Run"
        }
    ]
}

When I hit F5, I have the choices for selecting the different inputs, but I never hit any breakpoint…

The walkthrough shows an example for Android, and hints about MSBuild commands but I didn’t found any available information:

Have mentioned it for Android, iOS folks can refer to the MSBuild command to pass appropriate values for defining the iOS task as the parameters with prefix -p: are actually MSBuild properties.

Thanks for your help !

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img