From 4c92bf4fbdcbb39aee6891dfd362b0e32f411b4e Mon Sep 17 00:00:00 2001 From: Pier Fumagalli Date: Tue, 13 Apr 2021 23:35:20 +0200 Subject: [PATCH 1/3] Allow passing command line arguments when running an app in the iOS Simulator The `IOS_SIMULATOR_RUN_ARGS` environment variable allows specific command line arguments to be passed to the simulator when running an app. This is _extremely_ useful when working (for example) with Firebase and having to debug events or other internals: https://firebase.google.com/docs/analytics/debugview The command line arguments `-FIRDebugEnabled` and `-FIRDebugDisabled` control the behavior of Firebase in combination with its realtime event debugging console. With this patch, enabling debugging is as easy as calling: ```bash IOS_SIMULATOR_RUN_ARGS=-FIRDebugEnabled ns run ios ``` --- .../ios/simulator/ios-simulator-application-manager.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts b/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts index 46825e13aa..0c5828fdd3 100644 --- a/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts +++ b/lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts @@ -71,11 +71,14 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase { public async startApplication( appData: Mobile.IStartApplicationData ): Promise { + const args = process.env.IOS_SIMULATOR_RUN_ARGS || ""; const options = appData.waitForDebugger ? { waitForDebugger: true, - args: "--nativescript-debug-brk", + args: `--nativescript-debug-brk ${args}`.trim(), } + : args + ? { args } : {}; await this.setDeviceLogData(appData); const launchResult = await this.iosSim.startApplication( From c85a3de0dd068c4b8063980d92c7d6551ab22cff Mon Sep 17 00:00:00 2001 From: Pier Fumagalli Date: Tue, 13 Apr 2021 23:54:42 +0200 Subject: [PATCH 2/3] Add documentation for `IOS_SIMULATOR_RUN_ARGS` variable --- docs/man_pages/project/testing/run-ios.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/man_pages/project/testing/run-ios.md b/docs/man_pages/project/testing/run-ios.md index b1ac6bc916..2c4e9e7658 100644 --- a/docs/man_pages/project/testing/run-ios.md +++ b/docs/man_pages/project/testing/run-ios.md @@ -45,6 +45,10 @@ Start an emulator with specified device identifier and sdk | `$ tns run ios [--d * `--env.hiddenSourceMap` - creates sources maps in the root folder (useful for Crashlytics usage with bundled app in release). * `--force` - If set, skips the application compatibility checks and forces `npm i` to ensure all dependencies are installed. Otherwise, the command will check the application compatibility with the current CLI version and could fail requiring `tns migrate`. +### Environment Variables + +* `IOS_SIMULATOR_RUN_ARGS` - specifies extra command line arguments to pass to the application when running on the iOS Simulator. E.g. `$ IOS_SIMULATOR_RUN_ARGS=-FIRDebugEnabled tns device run ios`. + <% } %> <% if(isHtml) { %> From 4004d386b9a637b8ff6d25201befbde106cab83c Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Tue, 1 Jun 2021 10:01:22 +0200 Subject: [PATCH 3/3] Update docs/man_pages/project/testing/run-ios.md --- docs/man_pages/project/testing/run-ios.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/man_pages/project/testing/run-ios.md b/docs/man_pages/project/testing/run-ios.md index 2c4e9e7658..2217439c04 100644 --- a/docs/man_pages/project/testing/run-ios.md +++ b/docs/man_pages/project/testing/run-ios.md @@ -47,7 +47,7 @@ Start an emulator with specified device identifier and sdk | `$ tns run ios [--d ### Environment Variables -* `IOS_SIMULATOR_RUN_ARGS` - specifies extra command line arguments to pass to the application when running on the iOS Simulator. E.g. `$ IOS_SIMULATOR_RUN_ARGS=-FIRDebugEnabled tns device run ios`. +* `IOS_SIMULATOR_RUN_ARGS` - specifies extra command line arguments to pass to the application when running on the iOS Simulator. E.g. `$ IOS_SIMULATOR_RUN_ARGS=-FIRDebugEnabled ns device run ios`. <% } %> <% if(isHtml) { %>