Debugging
To debug an iOS application extension, provide thin integration with the CodeLLDB extension, powered by LLDB.
Tutorial
- Create a
launch.json
configuration file in the.vscode
directory of your project. The configuration file should contain the following configuration:
{
"version": "0.2.0",
"configurations": [
{
"type": "sweetpad-lldb",
"request": "launch",
"name": "Attach to running app (SweetPad)",
"preLaunchTask": "sweetpad: launch",
},
],
}
Also, you can create that file by clicking on the "Create a launch.json file" link in the Debug panel.
- Press
F5
to start debugging. The debugger will build and launch the application on the iOS simulator and then attach to the running application.
- Set breakpoints in your code and start debugging your application. Next time, you can just press
F5
to start and attach the debugger to the running application.
Old tutorial (deprecated)
Warning: This tutorial shows the old way of debugging iOS applications. It's deprecated, but it's still working.
- Install the CodeLLDB extension from the Visual Studio Code marketplace.
-
Create a
launch.json
configuration file in the.vscode
directory of your project. The configuration file should contain the following configuration: -
Now set breakpoints in your code and start debugging your application. Next time, you can just attach the debugger to the running application without the previous steps.
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "attach",
"name": "Attach to iOS Simulator",
"waitFor": true,
"program": "${command:sweetpad.debugger.getAppPath}",
},
],
}
Do you notice the
${command:sweetpad.debugger.getAppPath}
? This is a command that will be executed before debugging starts and will return the path to the application that was recently built by SweetPad. That path is required by the CodeLLDB extension in order to attach to the running application. You can read more about the CodeLLDB debugger options in the official documentation.
- Start the iOS simulator and run the application using the SweetPad "Launch" command on the "Build" panel. Wait until the application is launched on the simulator.
- Attach the debugger to the running application by clicking on the "Attach to iOS Simulator" configuration on the Debug panel. It takes a few seconds to attach the debugger to the running application. If you see the "Call Stack" panel with the list of threads and frames, then the debugger is successfully attached.
- Now set breakpoints in your code and start debugging your application. Next time, you can just attach the debugger to the running application without the previous steps.