From 6e4c61f3712f06f5eddcbb223ff93568a402a534 Mon Sep 17 00:00:00 2001 From: Peter Kanev Date: Tue, 7 Nov 2017 09:53:23 +0200 Subject: [PATCH] make default debug-ios behavior to use chrome-devtools instead of safari web inspector --- docs/man_pages/project/testing/debug-ios.md | 3 ++- lib/declarations.d.ts | 1 + lib/definitions/debug.d.ts | 5 +++++ lib/services/ios-debug-service.ts | 13 ++++++++----- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/man_pages/project/testing/debug-ios.md b/docs/man_pages/project/testing/debug-ios.md index cd0fb05da2..489a4122f6 100644 --- a/docs/man_pages/project/testing/debug-ios.md +++ b/docs/man_pages/project/testing/debug-ios.md @@ -26,7 +26,8 @@ While debugging, prints the output from the application in the console and watch * `--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. * `--no-watch` - If set, changes in your code will not be reflected during the execution of this command. * `--clean` - If set, forces rebuilding the native application. -* `--chrome` - Allows debugging in Chrome Developer Tools. If set Safari Web Inspector is not started and debugging is attached to Chrome Developer Tools. +* `--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. +* `--inspector` - If set, the developer tools in the Safari Web Inspector are used for debugging the application. ### Attributes * `` is the device identifier of the target device as listed by `$ tns device ios` diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index f7d56c0187..c54ea3281c 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -393,6 +393,7 @@ interface IOptions extends ICommonOptions, IBundle, IPlatformTemplate, IEmulator syncAllFiles: boolean; liveEdit: boolean; chrome: boolean; + inspector: boolean; // the counterpart to --chrome } interface IEnvOptions { diff --git a/lib/definitions/debug.d.ts b/lib/definitions/debug.d.ts index beed61b239..1128eb489c 100644 --- a/lib/definitions/debug.d.ts +++ b/lib/definitions/debug.d.ts @@ -82,6 +82,11 @@ interface IDebugOptions { * Default value is 02e6bde1bbe34e43b309d4ef774b1168d25fd024 which corresponds to 55.0.2883 Chrome version */ devToolsCommit?: string; + + /** + * Defines if the iOS App Inspector should be used instead of providing URL to debug the application with Chrome DevTools + */ + inspector?: boolean; } /** diff --git a/lib/services/ios-debug-service.ts b/lib/services/ios-debug-service.ts index 08bed47627..eff0c39f06 100644 --- a/lib/services/ios-debug-service.ts +++ b/lib/services/ios-debug-service.ts @@ -201,14 +201,17 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS } private async wireDebuggerClient(debugData: IDebugData, debugOptions: IDebugOptions, device?: Mobile.IiOSDevice): Promise { - if (debugOptions.chrome || !this.$hostInfo.isDarwin) { - this._socketProxy = await this.$socketProxyFactory.createWebSocketProxy(this.getSocketFactory(device)); - - return this.getChromeDebugUrl(debugOptions, this._socketProxy.options.port); - } else { + if (debugOptions.inspector && this.$hostInfo.isDarwin) { this._socketProxy = await this.$socketProxyFactory.createTCPSocketProxy(this.getSocketFactory(device)); await this.openAppInspector(this._socketProxy.address(), debugData, debugOptions); return null; + } else { + if (debugOptions.chrome) { + this.$logger.info("'--chrome' is the default behavior. Use --inspector to debug iOS applications using the Safari Web Inspector."); + } + + this._socketProxy = await this.$socketProxyFactory.createWebSocketProxy(this.getSocketFactory(device)); + return this.getChromeDebugUrl(debugOptions, this._socketProxy.options.port); } }