You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Chrome DevTools to debug iOS applications, CLI returns a url that points to a specific commit of the dev tools. This way, in case a new version of the dev tools introduces a breaking change, the debugging will still work.
However, in some cases (inside Electron app), we cannot use the remote url, so we must use the bundled one. So introduce a new option (only available when requiring CLI as a library), that defines that the returned url will use the bundled dev tools.
The default behavior (used in CLI), will still return the url that includes remote url.
Also change the definition of `debug` method in the interface, so now the DebugService can safely implement it.
Add a new check in the debug service - in case the device's status is not Connected, we are unable to start debug operation. So fail with correct error message in this case.
Add JSDocs for all debug related interfaces.
Add documentation in PublicAPI.md for the `debugService`.
Add debugService to tests of public API.
console.log(`Unable to start debug operation on device ${errorData.deviceId}. Error is: ${errorData.message}.`);
371
+
});
372
+
```
373
+
374
+
### debug
375
+
The `debug` method allows starting a debug operation for specified application on a specific device. The method returns a Promise, which is resolved with a url. The url should be opened in Chrome DevTools in order to debug the application.
376
+
377
+
The returned Promise will be rejected in case any error occurs. It will also be rejected in case:
378
+
1. Specified deviceIdentifier is not found in current list of attached devices.
379
+
1. The device, specified as deviceIdentifier is connected but not trusted.
380
+
1. The specified application is not installed on the device.
381
+
1. Trying to debug applications on connected iOS device on Linux.
382
+
1. In case the application is not running on the specified device.
383
+
1. In case the installed application is not built in debug configuration.
384
+
385
+
* Definition:
386
+
```TypeScript
387
+
/**
388
+
* Starts debug operation based on the specified debug data.
389
+
* @param{IDebugData}debugData Describes information for device and application that will be debugged.
390
+
* @param{IDebugOptions}debugOptions Describe possible options to modify the behaivor of the debug operation, for example stop on the first line.
391
+
* @returns{Promise<string>} URL that should be opened in Chrome DevTools.
console.log(`Unable to start debug operation on device ${errorData.deviceId}. Error is: ${errorData.message}.`);
443
+
});
444
+
445
+
constdebugData= {
446
+
deviceIdentifier:"4df18f307d8a8f1b",
447
+
applicationIdentifier:"com.telerik.app1",
448
+
projectName:"app1",
449
+
projectDir:"/Users/myUser/app1"
450
+
};
451
+
452
+
constdebugOptions= {
453
+
useBundledDevTools:true
454
+
};
455
+
456
+
tns.debugService.debug(debugData, debugOptions)
457
+
.then(url=>console.log(`Open the following url in Chrome DevTools: ${url}`))
458
+
.catch(err=>console.log(`Unable to start debug operation, reason: ${err.message}.`));
459
+
```
460
+
342
461
## How to add a new method to Public API
343
462
CLI is designed as command line tool and when it is used as a library, it does not give you access to all of the methods. This is mainly implementation detail. Most of the CLI's code is created to work in command line, not as a library, so before adding method to public API, most probably it will require some modification.
344
463
For example the `$options` injected module contains information about all `--` options passed on the terminal. When the CLI is used as a library, the options are not populated. Before adding method to public API, make sure its implementation does not rely on `$options`.
345
464
346
465
More information how to add a method to public API is available [here](https://github.com/telerik/mobile-cli-lib#how-to-make-a-method-public).
347
-
After that add each method that you've exposed to the tests in `tests/nativescript-cli-lib.ts` file. There you'll find an object describing each publicly available module and the methods that you can call.
466
+
After that add each method that you've exposed to the tests in `tests/nativescript-cli-lib.ts` file. There you'll find an object describing each publicly available module and the methods that you can call.
* Describes information for starting debug process.
3
+
*/
1
4
interfaceIDebugData{
5
+
/**
6
+
* Id of the device on which the debug process will be started.
7
+
*/
2
8
deviceIdentifier: string;
9
+
10
+
/**
11
+
* Application identifier of the app that it will be debugged.
12
+
*/
3
13
applicationIdentifier: string;
14
+
15
+
/**
16
+
* Path to .app built for iOS Simulator.
17
+
*/
4
18
pathToAppPackage?: string;
19
+
20
+
/**
21
+
* The name of the application, for example `MyProject`.
22
+
*/
5
23
projectName?: string;
24
+
25
+
/**
26
+
* Path to project.
27
+
*/
6
28
projectDir?: string;
7
29
}
8
30
31
+
/**
32
+
* Describes all options that define the behavior of debug.
33
+
*/
9
34
interfaceIDebugOptions{
35
+
/**
36
+
* Defines if Chrome-Dev Tools should be used for debugging.
37
+
*/
10
38
chrome?: boolean;
39
+
40
+
/**
41
+
* Defines if thе application is already started on device.
42
+
*/
11
43
start?: boolean;
44
+
45
+
/**
46
+
* Defines if we should stop the currently running debug process.
47
+
*/
12
48
stop?: boolean;
49
+
50
+
/**
51
+
* Defines if debug process is for emulator (not for real device).
52
+
*/
13
53
emulator?: boolean;
54
+
55
+
/**
56
+
* Defines if the debug process should break on the first line.
57
+
*/
14
58
debugBrk?: boolean;
59
+
60
+
/**
61
+
* Defines if the debug process will not have a client attached (i.e. the process will be started, but NativeScript Inspector will not be started and it will not attach to the running debug process).
62
+
*/
15
63
client?: boolean;
64
+
65
+
/**
66
+
* Defines if the process will watch for further changes in the project and transferrs them to device immediately, resulting in restar of the debug process.
67
+
*/
16
68
justlaunch?: boolean;
69
+
70
+
/**
71
+
* Defines if bundled Chrome DevTools should be used or specific commit. Valid for iOS only.
72
+
*/
73
+
useBundledDevTools?: boolean;
17
74
}
18
75
76
+
/**
77
+
* Describes methods to create debug data object used by other methods.
78
+
*/
19
79
interfaceIDebugDataService{
80
+
/**
81
+
* Creates the debug data based on specified options.
82
+
* @param {IProjectData} projectData The data describing project that will be debugged.
83
+
* @param {IOptions} options The options based on which debugData will be created
84
+
* @returns {IDebugData} Data describing the required information for starting debug process.
this.$errors.failWithoutHelp(`The application ${debugData.applicationIdentifier} is not installed on device with identifier ${debugData.deviceIdentifier}.`);
28
31
}
@@ -51,9 +54,9 @@ class DebugService extends EventEmitter {
51
54
this.$errors.failWithoutHelp(`Debugging on iOS devices is not supported for ${platform()} yet.`);
0 commit comments