Skip to content

Commit f7e1848

Browse files
Add --sdk as parameter
When CLI uses ios-sim-portable through require("ios-sim-portable"), this module must understand the same command line parameters as the one passed to NativeScript CLI / AppBuilder CLI. The option there is called `--sdk`, while here it is `--sdkVersion`. Add `--sdk` here, so ios-sim-portable will pass it and use it to start the correct emulator.
1 parent 26aa923 commit f7e1848

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

lib/iphone-interop-simulator-base.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export class IPhoneInteropSimulatorBase extends IPhoneSimulatorNameGetter {
8484
config("setApplicationToSimulateOnStart", appSpec);
8585
config("setSimulatedApplicationShouldWaitForDebugger", options.waitForDebugger);
8686

87-
let sdkRoot = options.sdkVersion ? $(this.getSdkRootPathByVersion(options.sdkVersion)) : this.getClassByName("DTiPhoneSimulatorSystemRoot")("defaultRoot");
87+
let sdkVersion = options.sdkVersion || options.sdk;
88+
let sdkRoot = sdkVersion ? $(this.getSdkRootPathByVersion(sdkVersion)) : this.getClassByName("DTiPhoneSimulatorSystemRoot")("defaultRoot");
8889
config("setSimulatedSystemRoot", sdkRoot);
8990

9091
this.validateDevice();

lib/iphone-simulator-xcode-7.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,23 @@ export class XCode7Simulator extends IPhoneSimulatorNameGetter implements ISimul
104104

105105
private getDeviceToRun(): IFuture<IDevice> {
106106
return (() => {
107-
let devices = this.simctl.getDevices().wait();
107+
let devices = this.simctl.getDevices().wait(),
108+
sdkVersion = options.sdkVersion || options.sdk;
109+
108110
let result = _.find(devices, (device: IDevice) => {
109-
if(options.sdkVersion && !options.device) {
110-
return device.runtimeVersion === options.sdkVersion;
111+
if(sdkVersion && !options.device) {
112+
return device.runtimeVersion === sdkVersion;
111113
}
112114

113-
if(options.device && !options.sdkVersion) {
115+
if(options.device && !sdkVersion) {
114116
return device.name === options.device;
115117
}
116118

117-
if(options.device && options.sdkVersion) {
118-
return device.runtimeVersion === options.sdkVersion && device.name === options.device;
119+
if(options.device && sdkVersion) {
120+
return device.runtimeVersion === sdkVersion && device.name === options.device;
119121
}
120122

121-
if(!options.sdkVersion && !options.device) {
123+
if(!sdkVersion && !options.device) {
122124
return this.isDeviceBooted(device);
123125
}
124126
});

lib/iphone-simulator.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ export class iPhoneSimulator implements IiPhoneSimulator {
3737
}
3838
}
3939

40-
if(options.sdkVersion) {
40+
let sdkVersion = options.sdkVersion || options.sdk;
41+
if(sdkVersion) {
4142
let runtimeVersions = _.unique(_.map(this.simulator.getDevices().wait(), (device: IDevice) => device.runtimeVersion));
42-
if(!_.contains(runtimeVersions, options.sdkVersion)) {
43-
errors.fail(`Unable to find sdk ${options.sdkVersion}. The valid runtime versions are ${runtimeVersions.join(", ")}`);
43+
if(!_.contains(runtimeVersions, sdkVersion)) {
44+
errors.fail(`Unable to find sdk ${sdkVersion}. The valid runtime versions are ${runtimeVersions.join(", ")}`);
4445
}
4546
}
4647

lib/options.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/options.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ var knownOptions: any = {
2020
"help": { type: OptionType.Boolean },
2121
"logging": { type: OptionType.Boolean },
2222
"waitForDebugger": { type: OptionType.Boolean },
23-
"sdkVersion": { type: OptionType.String }
23+
"sdkVersion": { type: OptionType.String }, // Obsolete, use sdk instead.
24+
"sdk": { type: OptionType.String }
2425
};
2526

2627
var parsed: any = {};

0 commit comments

Comments
 (0)