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 Fatme Havaluova committed Oct 1, 2015
1 parent af44291 commit cce926c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 34 deletions.
50 changes: 34 additions & 16 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 @@ -142,7 +129,7 @@ export class iPhoneSimulator implements IiPhoneSimulator {
var config = this.getClassByName("DTiPhoneSimulatorSessionConfig")("alloc")("init")("autorelease");
config("setApplicationToSimulateOnStart", appSpec);

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 @@ -303,6 +290,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 @@ -13,7 +13,8 @@ var knownOptions: any = {
"args": String,
"timeout": String,
"help": Boolean,
"logging": Boolean
"logging": Boolean,
"sdkVersion": String
};

var parsed: any = {};
Expand Down

0 comments on commit cce926c

Please sign in to comment.