sweetpad icon indicating copy to clipboard operation
sweetpad copied to clipboard

Debugger terminates immediately after app launch on physical iOS device

Open Lieutenant-K opened this issue 10 months ago • 8 comments

Hi. I have discovered that when building and running an iOS app on a physical device, the debugger terminates immediately. The issue does not occur when using the iPhone simulator. Are there any known compatibility issues between Cursor AI, CodeLLDB, and Sweetpad when debugging on physical iOS devices? Or, Are there any specific settings or configurations required for debugging on physical devices that differ from simulator debugging?

Description

When attempting to install, run, and debug an iOS app on a physical device using Cursor AI editor with CodeLLDB and Sweetpad plugins, the app builds and launches successfully, but LLDB terminates immediately after the app starts running. This issue does not occur when using the iPhone simulator, where LLDB functions normally.

Steps to Reproduce

  1. Install CodeLLDB and Sweetpad plugins in Cursor AI editor.
  2. Set up an iOS project for debugging on a physical device.
  3. Build and run the app on the device.
  4. Observe that the app launches, but LLDB terminates shortly after.

Expected Behavior

LLDB should remain active and allow debugging on the physical iOS device, similar to its behavior on the iPhone simulator.

Actual Behavior

LLDB terminates immediately after the app launches on the physical device, preventing any debugging capabilities.

Environment

  • Cursor AI Editor Version: 0.45.11
  • VSCode Version: 1.96.2
  • Sweetpad Version: 0.1.51
  • CodeLLDB Version: 1.11.3
  • Xcode Version: 16.2
  • iOS Device: iPhone 13 Pro, 17.6.1
Terminal message after build success
Build Succeeded

🚀 Executing command:
xcrun devicectl device install app --device {device}/Users/{user}/Library/Developer/Xcode/DerivedData/MyApp-fuwrfbvmcckczfhjosrgspqbqihc/Build/Products/Debug-iphoneos/MyApp.app

16:32:31  Acquired tunnel connection to device.
16:32:31  Enabling developer disk image services.
16:32:31  Acquired usage assertion.
5%... 10%... 24%... 25%... 27%... 30%... 35%... 36%... 37%... 44%... 46%... 48%... 49%... 50%... 51%... 52%... 53%... 54%... 55%... 56%... 57%... 60%... 62%... 66%... 68%... 72%... 74%... 76%... 80%... 84%... 88%... 92%... 96%... Complete!
App installed:
? bundleID: {appId}
? installationURL: file:///private/var/containers/Bundle/Application/{directory}/MyApp.app/
? launchServicesIdentifier: unknown
? databaseUUID: {uuid}
? databaseSequenceNumber: 12936
? options: 

🍭 Sweetpad: watch marker (start)
🍩 Sweetpad: watch marker (end)

🚀 Executing command:
xcrun devicectl device process launch --console --json-output '/Users/{user}/Library/Application Support/Cursor/User/workspaceStorage/a78760739926debf1c42fbbbd1e191d4/sweetpad.sweetpad/_temp/json_c36d557d' --terminate-existing --device {device}{appId}
Debug Console
Could not initialize Python interpreter - some features will be unavailable (e.g. debug visualizers).
Console is in 'commands' mode, prefix expressions with '?'.
Executing script: initCommands
  Platform: remote-ios
 Connected: no
  SDK Path: "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 17.6.1 (21G93)"
 SDK Roots: [ 0] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 17.6.1 (21G93)"
 SDK Roots: [ 1] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 18.0 (22A3354)"
 SDK Roots: [ 2] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 17.4.1 (21E236)"
 SDK Roots: [ 3] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 17.5.1 (21F90)"
 SDK Roots: [ 4] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 18.1.1 (22B91)"
 SDK Roots: [ 5] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 18.1 (22B83)"
 SDK Roots: [ 6] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 18.0.1 (22A3370)"

warning: (arm64) /Users/{Name}/Library/Developer/Xcode/DerivedData/MyApp-fuwrfbvmcckczfhjosrgspqbqihc/Build/Products/Debug-iphoneos/MyApp.app/MyApp empty dSYM file detected, dSYM was created with an executable with no debug info.
Executing script: preRunCommands
True
True

Executing script: processCreateCommands
Attached to process 2114
Process exited with code -1.
LLDB Output
Launching adapter
liblldb: /Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB
environment: {}
settings: { evaluateForHovers: true, commandCompletions: true }
[ERROR codelldb] Initialize Python interpreter: Error:  Fail
    Error Message:
    error: module importing failed: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "[EXTENSION_PATH]/codelldb/__init__.py", line 1, in <module>
        from .api import evaluate, wrap, unwrap, get_config, create_webview, display_html, debugger_message
      File "[EXTENSION_PATH]/codelldb/api.py", line 6, in <module>
        from . import interface
      File "[EXTENSION_PATH]/codelldb/interface.py", line 322, in <module>
        current_exec_context: lldb.SBExecutionContext | None = None
    TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
    
warning: (arm64) [BUILD_PATH]/MyApp.app/MyApp empty dSYM file detected, dSYM was created with an executable with no debug info.
Debug adapter exit code=0 (0x0), signal=null.

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

Lieutenant-K avatar Feb 10 '25 07:02 Lieutenant-K

same with me

987N avatar Apr 02 '25 03:04 987N

I have the same problem too.

smurat avatar Apr 03 '25 22:04 smurat

I edit ~/.vscode/extensions/vadimcn.vscode-lldb-1.11.4/adapter/scripts/codelldb/interface.py change current_exec_context: lldb.SBExecutionContext | None = None to try: from typing import Optional current_exec_context = None # type: Optional[lldb.SBExecutionContext] except: current_exec_context = None this fix [ERROR codelldb] Initialize Python interpreter: Error: Fail

but still ` Console is in 'commands' mode, prefix expressions with '?'. Executing script: initCommands Platform: remote-ios Connected: no SDK Path: "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 17.6.1 (21G93)" SDK Roots: [ 0] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 17.6.1 (21G93)" SDK Roots: [ 1] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 18.0 (22A3354)" SDK Roots: [ 2] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 17.4.1 (21E236)" SDK Roots: [ 3] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 17.5.1 (21F90)" SDK Roots: [ 4] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 18.1.1 (22B91)" SDK Roots: [ 5] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 18.1 (22B83)" SDK Roots: [ 6] "/Users/{Name}/Library/Developer/Xcode/iOS DeviceSupport/iPhone14,2 18.0.1 (22A3370)"

warning: (arm64) /Users/{Name}/Library/Developer/Xcode/DerivedData/MyApp-fuwrfbvmcckczfhjosrgspqbqihc/Build/Products/Debug-iphoneos/MyApp.app/MyApp empty dSYM file detected, dSYM was created with an executable with no debug info. Executing script: preRunCommands True True

Executing script: processCreateCommands Attached to process 2114 Process exited with code -1. `

987N avatar Apr 13 '25 15:04 987N

Could not initialize Python interpreter - some features will be unavailable (e.g. debug visualizers).
Console is in 'commands' mode, prefix expressions with '?'.
Executing script: initCommands
  Platform: remote-ios
 Connected: no
  SDK Path: "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/15.8.2 (19H384)"
 SDK Roots: [ 0] "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/iPad6,12 14.8.1 (18H107)"
 SDK Roots: [ 1] "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/iPad11,7 17.6.1 (21G93)"
 SDK Roots: [ 2] "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/iPad12,1 18.4.1 (22E252)"
 SDK Roots: [ 3] "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/iPad7,11 18.0 (22A3354)"
 SDK Roots: [ 4] "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/iPad11,7 16.1.1 (20B101)"
 SDK Roots: [ 5] "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/15.8.2 (19H384)"
 SDK Roots: [ 6] "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/iPad6,12 16.7.11 (20H360)"
 SDK Roots: [ 7] "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/14.8.1 (18H107)"
 SDK Roots: [ 8] "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/iPad5,4 15.8.2 (19H384)"
 SDK Roots: [ 9] "/Users/harish/Library/Developer/Xcode/iOS DeviceSupport/iPad12,1 18.4 (22E240)"

NAME         PASS     STOP     NOTIFY
===========  =======  =======  =======
SIGSTOP      true     false    false  

Executing script: preRunCommands
True
True

Executing script: processCreateCommands
Attached to process 3385
Executing script: postRunCommands
SweetPad: Happy debugging!
SweetPad: Happy debugging!```

Harishwarrior avatar May 13 '25 06:05 Harishwarrior

same with me

dabuddha avatar Jun 17 '25 16:06 dabuddha

same with me

leaflinfeng avatar Jun 19 '25 03:06 leaflinfeng

same with me

with lldb debug log:

DEBUG codelldb::debug_session] Debug event: 0x5c5089ed0 Event: broadcaster = 0x5c49de238 (lldb.process), type = 0x00000001 (state-changed), data = { process = 0x5c49de200 (pid = 86910), state = exited} [DEBUG codelldb::dap_codec] <-- {"seq":33,"type":"event","event":"output","body":{"category":"console","output":"Process exited with code -1.\n"}} [DEBUG codelldb::dap_codec] <-- {"seq":34,"type":"event","event":"exited","body":{"exitCode":-1}} [DEBUG codelldb::dap_codec] <-- {"seq":35,"type":"event","event":"terminated","body":{}} [DEBUG codelldb::dap_codec] --> {"command":"disconnect","arguments":{"restart":false,"terminateDebuggee":false},"type":"request","seq":10} [DEBUG codelldb::dap_codec] <-- {"seq":36,"type":"response","request_seq":10,"success":true,"command":"disconnect"} [DEBUG codelldb::dap_session] The client has disconnected [DEBUG codelldb::debug_session] End of the requests stream [DEBUG codelldb::debug_session] DebugSession::drop() [DEBUG codelldb] End of the debug session [DEBUG codelldb] Exiting Debug adapter exit code=0, signal=null.

leaflinfeng avatar Jun 19 '25 03:06 leaflinfeng

same with me

Taeyss avatar Aug 01 '25 06:08 Taeyss