forked from sweetpad-dev/sweetpad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
216 additions
and
29 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Debugging iOS application | ||
|
||
To debug an iOS application extension, provide thin integration with the | ||
[CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) extension, powered by | ||
[LLDB](https://lldb.llvm.org/). | ||
|
||
## Tutorial | ||
|
||
1. Install the [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) extension from the | ||
Visual Studio Code marketplace. | ||
|
||
![Install CodeLLDB](../images/debug-install-codelldb.png) | ||
|
||
2. Create a `launch.json` configuration file in the `.vscode` directory of your project. The configuration file should | ||
contain the following configuration: | ||
|
||
```json | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "lldb", | ||
"request": "attach", | ||
"name": "Attach to iOS Simulator", | ||
"waitFor": true, | ||
"program": "${command:sweetpad.debugger.getAppPath}" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
![Create launch.json](../images/debug-create-launch-json.png) | ||
|
||
![Update launch.json](../images/debug-update-launch-json.png) | ||
|
||
> 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](https://github.com/vadimcn/codelldb/blob/master/MANUAL.md). | ||
3. 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. | ||
|
||
![Launch](../images/debug-launch-app.png) | ||
|
||
4. 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. | ||
|
||
![Attach](../images/debug-attach-ios-simulator.png) | ||
|
||
5. 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. | ||
|
||
![Breakpoints](../images/debug-breakpoints.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { CommandExecution } from "../common/commands"; | ||
import { ExtensionError } from "../common/errors"; | ||
import * as vscode from "vscode"; | ||
|
||
const DEBUG_DOCUMENTATION_URL = "https://github.com/sweetpad-dev/sweetpad/blob/main/docs/wiki/debug.md"; | ||
|
||
export async function getAppPathCommand(execution: CommandExecution): Promise<string> { | ||
const sessionPath = execution.context.getSessionState<string>("build.lastLaunchedAppPath"); | ||
if (!sessionPath) { | ||
throw new ExtensionError(`No last launched app path found, please launch the app first using the extension`, { | ||
actions: [ | ||
{ | ||
label: "Open documentation", | ||
callback: () => vscode.env.openExternal(vscode.Uri.parse(DEBUG_DOCUMENTATION_URL)), | ||
}, | ||
], | ||
}); | ||
} | ||
return sessionPath; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import vscode from "vscode"; | ||
import { ExtensionContext } from "../common/commands"; | ||
|
||
const ATTACH_CONFIG: vscode.DebugConfiguration = { | ||
type: "lldb", | ||
request: "attach", | ||
name: "Attach to iOS Simulator (SweetPad)", | ||
waitFor: true, | ||
program: "${command:sweetpad.debugger.getAppPath}", | ||
}; | ||
|
||
export class DebuggerConfigurationProvider implements vscode.DebugConfigurationProvider { | ||
async provideDebugConfigurations( | ||
folder: vscode.WorkspaceFolder | undefined, | ||
token?: vscode.CancellationToken | undefined | ||
): Promise<vscode.DebugConfiguration[]> { | ||
return [ATTACH_CONFIG]; | ||
} | ||
|
||
async resolveDebugConfiguration( | ||
folder: vscode.WorkspaceFolder | undefined, | ||
config: vscode.DebugConfiguration, | ||
token?: vscode.CancellationToken | undefined | ||
): Promise<vscode.DebugConfiguration> { | ||
// currently doing nothing useful here, but leave it for future extension | ||
return config; | ||
} | ||
|
||
async resolveDebugConfigurationWithSubstitutedVariables( | ||
folder: vscode.WorkspaceFolder | undefined, | ||
config: vscode.DebugConfiguration, | ||
token?: vscode.CancellationToken | undefined | ||
): Promise<vscode.DebugConfiguration> { | ||
// currently doing nothing useful here, but leave it for future extension | ||
return config; | ||
} | ||
} | ||
|
||
export function registerDebugConfigurationProvider(context: ExtensionContext) { | ||
vscode.debug.registerDebugConfigurationProvider( | ||
"lldb", | ||
new DebuggerConfigurationProvider(), | ||
vscode.DebugConfigurationProviderTriggerKind.Initial | ||
); | ||
return vscode.debug.registerDebugConfigurationProvider( | ||
"lldb", | ||
new DebuggerConfigurationProvider(), | ||
vscode.DebugConfigurationProviderTriggerKind.Dynamic | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters