Skip to content

Commit

Permalink
Support for sdkVersion option
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatme Havaluova authored and teobugslayer committed Oct 22, 2015
1 parent 94615f3 commit 94938b6
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 30 deletions.
36 changes: 24 additions & 12 deletions lib/iphone-simulator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 32 additions & 16 deletions lib/iphone-simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,9 @@ export class iPhoneSimulator implements IiPhoneSimulator {

public printSDKS(): IFuture<void> {
var action = () => {
var systemRootClass = this.getClassByName("DTiPhoneSimulatorSystemRoot");
var roots = systemRootClass("knownRoots");
var count = roots("count");

var sdks: ISdk[] = [];
for(var index=0; index < count; index++) {
var root = roots("objectAtIndex", index);

var displayName = root("sdkDisplayName").toString();
var version = root("sdkVersion").toString();
var rootPath = root("sdkRootPath").toString();

sdks.push(new Sdk(displayName, version, rootPath));
}

var sdks = this.getInstalledSdks();
sdks = _.sortBy(sdks, (sdk: ISdk) => sdk.version);

_.each(sdks, (sdk: ISdk) => console.log(sdk.sdkInfo() + os.EOL));
};

Expand Down Expand Up @@ -145,7 +132,7 @@ export class iPhoneSimulator implements IiPhoneSimulator {
config("setApplicationToSimulateOnStart", appSpec);
config("setSimulatedApplicationShouldWaitForDebugger", options.waitForDebugger);

var sdkRoot = options.sdkRoot ? $(options.sdkRoot) : this.getClassByName("DTiPhoneSimulatorSystemRoot")("defaultRoot");
var sdkRoot = options.sdkVersion ? $(this.getSdkRootPathByVersion(options.sdkVersion)) : this.getClassByName("DTiPhoneSimulatorSystemRoot")("defaultRoot");
config("setSimulatedSystemRoot", sdkRoot);

var simulator = this.createSimulator(config);
Expand Down Expand Up @@ -306,6 +293,35 @@ export class iPhoneSimulator implements IiPhoneSimulator {

return future;
}

private getInstalledSdks(): ISdk[] {
var systemRootClass = this.getClassByName("DTiPhoneSimulatorSystemRoot");
var roots = systemRootClass("knownRoots");
var count = roots("count");

var sdks: ISdk[] = [];
for(var index=0; index < count; index++) {
var root = roots("objectAtIndex", index);

var displayName = root("sdkDisplayName").toString();
var version = root("sdkVersion").toString();
var rootPath = root("sdkRootPath").toString();

sdks.push(new Sdk(displayName, version, rootPath));
}

return sdks;
}

private getSdkRootPathByVersion(version: string): string {
var sdks = this.getInstalledSdks();
var sdk = _.find(sdks, sdk => sdk.version === version);
if(!sdk) {
errors.fail("Unable to find installed sdk with version %s. Verify that you have specified correct version and the sdk with that version is installed.", version);
}

return sdk.rootPath;
}
}

class Sdk implements ISdk {
Expand Down
3 changes: 2 additions & 1 deletion lib/options.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ var knownOptions: any = {
"timeout": String,
"help": Boolean,
"logging": Boolean,
"waitForDebugger": Boolean
"waitForDebugger": Boolean,
"sdkVersion": String
};

var parsed: any = {};
Expand Down

0 comments on commit 94938b6

Please sign in to comment.