sweetpad: Unable to debug on physical device

Thank you very much for creating this plugin. I really like it.

However, I’ve found that I can’t debug on a physical device. Is there something wrong with my configuration?

My plugin version is 0.1.33.

I’m using Xcode 15.2, and my phone’s system is iOS 17.6.1.

My launch.json configuration is as follows:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "sweetpad-lldb",
            "request": "launch",
            "name": "Attach to running app (SweetPad)",
            "preLaunchTask": "sweetpad: launch",
        },
    ],
}

When I use VSCode’s debug feature, the Terminal outputs:

Result bundle written to path:
Build Succeeded

🚀 Executing command:
xcrun devicectl device install app --device iosdevice-00008020-000B34D6012A003F /Users/myname/Library/Developer/Xcode/DerivedData/myapp-djwiypcpaflfvkbkckuttoyimesk/Build/Products/Debug-iphoneos/myapp.app

ERROR: The specified device was not found. (com.apple.dt.CoreDeviceError error 1000.)

🚫 Command returned non-zero exit code

When I use the command: SweetPad: Build & Run (Launch), the Terminal outputs:

Result bundle written to path:
Build Succeeded

🚀 Executing command:
xcrun devicectl device install app --device 00008020-000B34D6012A003F /Users/myname/Library/Developer/Xcode/DerivedData/myapp-djwiypcpaflfvkbkckuttoyimesk/Build/Products/Debug-iphoneos/myapp.app

21:59:41  Acquired tunnel connection to device.
21:59:41  Enabling developer disk image services.
21:59:41  Acquired usage assertion.
1%... 2%... 3%... 4%... 5%... 6%... 7%... 8%... 9%... 10%... 11%... 12%... 13%... 14%... 15%... 16%... 18%... 19%... 20%... 21%... 22%... 23%... 24%... 25%... 26%... 27%... 28%... 30%... 31%... 32%... 33%... 34%... 35%... 36%... 37%... 38%... 39%... 40%... 41%... 42%... 43%... 44%... 45%... 46%... 47%... 48%... 49%... 50%... 51%... 52%... 53%... 54%... 55%... 56%... 57%... 59%... 60%... 62%... 66%... 68%... 72%... 74%... 76%... 80%... 84%... 88%... 92%... 96%... Complete!
App installed:
? bundleID: com.myapp.ios
? installationURL: file:///private/var/containers/Bundle/Application/689DB382-C1B9-4626-B4D7-56ADEA7B5021/myapp.app/
? launchServicesIdentifier: unknown
? databaseUUID: E1D4A799-1D0D-4931-A385-74A49B4B3FD7
? databaseSequenceNumber: 1268
? options: 

🚀 Executing command:
xcrun devicectl device process launch --json-output '/Users/myname/Library/Application Support/Cursor/User/workspaceStorage/f8d9db3c1fcf7403dae4fe89e60093e3/sweetpad.sweetpad/_temp/json_f54f27f0' --terminate-existing --device 00008020-000B34D6012A003F com.myapp.ios

22:00:12  Acquired tunnel connection to device.
22:00:13  Enabling developer disk image services.
22:00:13  Acquired usage assertion.
Launched application with com.myapp.ios bundle identifier.

App launched on device with PID: 872
✅ Task completed

When using VSCode’s debug feature, the --device parameter is: iosdevice-00008020-000B34D6012A003F (may be wrong)

When using SweetPad’s debug feature, the --device parameter is: 00008020-000B34D6012A003F

Additionally, when I use SweetPad: Get app path for debugging, it pops up an error:

Sweetpad: No last launched app path found, please launch the app first using the extension

I’ve noticed that when running on a physical device, build.lastLaunchedAppPath is not updated. I’m not sure if this is related.

I would greatly appreciate if you could look into this issue. I’m really looking forward to debugging on a physical device.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 24 (4 by maintainers)

Most upvoted comments

I’ve attempted and released a fix in v0.4.1 of vscode-ios-debug for iOS 17+ (with Xcode 16+) support. Thought it might be useful here.

Great! It’s really easy now to launch debug. With following config you may install, launch and debug:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "iOS Debug",
            "type": "lldb",
            "request": "launch",
            "program": "${command:sweetpad.debugger.getAppPath}",
            "iosBundleId": "YOUR BUNDLE ID",
            "iosTarget": "select",
            "preLaunchTask": "sweetpad: build"
        }
    ]
}

In the latest version (0.1.34), I’ve added the --console option for launching on physical devices. This option will redirect stdout to the extension, allowing you to print debug information on a physical device.

–console — Attaches the application to the console and waits for it to exit. devicectl will wait for the app to terminate. Catchable signals sent to devicectl are forwarded to the app. If the app is not already running, its standard streams will be connected to devicectl’s standard streams.


I’d like to try implementing this feature and hope to be of some help.

Thank you! That would be amazing! 💜

I think a good starting point for configuring proper debugging with LLDB is to check this comment in the Flutter project: https://github.com/flutter/flutter/issues/133465#issuecomment-2159512125. From my understanding, launching an LLDB session with devicectl works only with Xcode 16 and requires running these commands in the LLDB session.

(lldb) device select <device-identifier>
(lldb) device process attach --pid <pid>

In my extension, I heavily rely on the CodeLLDB extension for LLDB debugging and my extension just provide the correct options to this extension based on project information. Most of the logic is located in the DebuggerConfigurationProvider class. Additionally, I’ve prepared a document on how to debug the extension on a local machine. This is also applicable for development, but rememeber to fork the project instead of just cloning it: Debugging extension.

If you have any other questions or ideas, don’t hesitate to contact me

Just for notice: new changes allows to attach to running application on ios device and this is great, but there is one use case where you will still need vscode-ios-debug.

@kvaster I am not able to attach to app running on device. Getting the following error:

Image

My launch.json entry:

 {
      "type": "sweetpad-lldb",
      "request": "attach",
      "name": "Attach to running app (SweetPad)",
      "preLaunchTask": "sweetpad: launch"
  }

If you your app crashes right after start or you need to debug app initialization - you will need to use vscode-ios-debug, cause it allows to launch and pause app right at the start.

I think that would be because when starting the app --start-stopped flag is not passed to devicectl device process launch.

I’m able to debug app using folowing patch and vscode-ios-debug extension (patched for Xcode 16): https://github.com/sweetpad-dev/sweetpad/pull/76

Thank you very much, I can run it on a physical device.

I would be extremely grateful if you could explain the challenges of debugging on a physical device.

I’d like to try implementing this feature and hope to be of some help.