Skip to content

Commit 009861c

Browse files
committed
make default debug-ios behavior to use chrome-devtools instead of safari web inspector
1 parent 38016f5 commit 009861c

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

docs/man_pages/project/testing/debug-ios.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ While debugging, prints the output from the application in the console and watch
2626
* `--timeout` - Sets the number of seconds that NativeScript CLI will wait for the simulator/device to boot. If not set, the default timeout is 90 seconds.
2727
* `--no-watch` - If set, changes in your code will not be reflected during the execution of this command.
2828
* `--clean` - If set, forces rebuilding the native application.
29-
* `--chrome` - Allows debugging in Chrome Developer Tools. If set Safari Web Inspector is not started and debugging is attached to Chrome Developer Tools.
29+
* `--chrome` - Deprecated - default behavior uses '--chrome' implicitly. Allows debugging in Chrome Developer Tools. If set, Safari Web Inspector is not started and debugging is attached to Chrome Developer Tools.
30+
* `--inspector` - If set, the developer tools in the Safari Web Inspector are used for debugging the application.
3031

3132
### Attributes
3233
* `<Device ID>` is the device identifier of the target device as listed by `$ tns device ios`

lib/declarations.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ interface IOptions extends ICommonOptions, IBundle, IPlatformTemplate, IEmulator
393393
syncAllFiles: boolean;
394394
liveEdit: boolean;
395395
chrome: boolean;
396+
inspector: boolean; // the counterpart to --chrome
396397
}
397398

398399
interface IEnvOptions {

lib/definitions/debug.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ interface IDebugOptions {
8282
* Default value is 02e6bde1bbe34e43b309d4ef774b1168d25fd024 which corresponds to 55.0.2883 Chrome version
8383
*/
8484
devToolsCommit?: string;
85+
86+
/**
87+
* Defines if the iOS App Inspector should be used instead of providing URL to debug the application with Chrome DevTools
88+
*/
89+
inspector?: boolean;
8590
}
8691

8792
/**

lib/services/ios-debug-service.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
2525
private $platformService: IPlatformService,
2626
private $iOSEmulatorServices: Mobile.IEmulatorPlatformServices,
2727
private $childProcess: IChildProcess,
28-
private $hostInfo: IHostInfo,
2928
private $logger: ILogger,
3029
private $errors: IErrors,
3130
private $npmInstallationManager: INpmInstallationManager,
@@ -201,14 +200,17 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
201200
}
202201

203202
private async wireDebuggerClient(debugData: IDebugData, debugOptions: IDebugOptions, device?: Mobile.IiOSDevice): Promise<string> {
204-
if (debugOptions.chrome || !this.$hostInfo.isDarwin) {
205-
this._socketProxy = await this.$socketProxyFactory.createWebSocketProxy(this.getSocketFactory(device));
206-
207-
return this.getChromeDebugUrl(debugOptions, this._socketProxy.options.port);
208-
} else {
203+
if (debugOptions.inspector) {
209204
this._socketProxy = await this.$socketProxyFactory.createTCPSocketProxy(this.getSocketFactory(device));
210205
await this.openAppInspector(this._socketProxy.address(), debugData, debugOptions);
211206
return null;
207+
} else {
208+
if (debugOptions.chrome) {
209+
this.$logger.info("'--chrome' is the default behavior. Use --inspector to debug iOS applications using the Safari Web Inspector.");
210+
}
211+
212+
this._socketProxy = await this.$socketProxyFactory.createWebSocketProxy(this.getSocketFactory(device));
213+
return this.getChromeDebugUrl(debugOptions, this._socketProxy.options.port);
212214
}
213215
}
214216

test/services/ios-debug-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class IOSDebugServiceInheritor extends IOSDebugService {
1818
$iOSSocketRequestExecutor: IiOSSocketRequestExecutor,
1919
$processService: IProcessService,
2020
$socketProxyFactory: ISocketProxyFactory) {
21-
super(<any>{}, $devicesService, $platformService, $iOSEmulatorServices, $childProcess, $hostInfo, $logger, $errors,
21+
super(<any>{}, $devicesService, $platformService, $iOSEmulatorServices, $childProcess, $logger, $errors,
2222
$npmInstallationManager, $iOSNotification, $iOSSocketRequestExecutor, $processService, $socketProxyFactory);
2323
}
2424

0 commit comments

Comments
 (0)