Skip to content

Commit 6b700b4

Browse files
pfumagallirigor789
andauthored
feat: allow passing cli args when running in the iOS Simulator (#5518)
* 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 ``` * Add documentation for `IOS_SIMULATOR_RUN_ARGS` variable * Update docs/man_pages/project/testing/run-ios.md Co-authored-by: Igor Randjelovic <[email protected]>
1 parent ce0c714 commit 6b700b4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ Start an emulator with specified device identifier and sdk | `$ tns run ios [--d
4545
* `--env.hiddenSourceMap` - creates sources maps in the root folder (useful for Crashlytics usage with bundled app in release).
4646
* `--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`.
4747

48+
### Environment Variables
49+
50+
* `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`.
51+
4852
<% } %>
4953
<% if(isHtml) { %>
5054

lib/common/mobile/ios/simulator/ios-simulator-application-manager.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ export class IOSSimulatorApplicationManager extends ApplicationManagerBase {
7171
public async startApplication(
7272
appData: Mobile.IStartApplicationData
7373
): Promise<void> {
74+
const args = process.env.IOS_SIMULATOR_RUN_ARGS || "";
7475
const options = appData.waitForDebugger
7576
? {
7677
waitForDebugger: true,
77-
args: "--nativescript-debug-brk",
78+
args: `--nativescript-debug-brk ${args}`.trim(),
7879
}
80+
: args
81+
? { args }
7982
: {};
8083
await this.setDeviceLogData(appData);
8184
const launchResult = await this.iosSim.startApplication(

0 commit comments

Comments
 (0)