Skip to content

Commit

Permalink
Fixed for Xcode 8 and Xcode 9 quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
shazron committed Sep 17, 2017
1 parent 5295a74 commit 1ec43d8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
34 changes: 30 additions & 4 deletions lib/simctl-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,36 @@ var shell = require('shelljs'),

var extensions = {
start: function(deviceid) {
shell.exec('killall "Simulator"', { silent: true });
var command = util.format(
'open `xcode-select -p`/Applications/Simulator.app --args -CurrentDeviceUDID "%s"', deviceid);
return shell.exec(command, { silent: true });
var is_at_least_xcode_9 = false;

var command = 'killall Simulator';
shell.exec(command, { silent: true });

command = 'xcodebuild -version';
var output = shell.exec(command, { silent: true }).output;

// parse output for Xcode version
var versionMatch = /Xcode (.*)/.exec(output);
if (!versionMatch) {
console.log('Unable to parse xcodebuild version.');
return;
} else {
is_at_least_xcode_9 = (parseInt(versionMatch[1]) >= 9);
}

if (is_at_least_xcode_9) {
// Xcode 9 or greater
command = util.format('xcrun simctl boot "%s"', deviceid);
shell.exec(command, { silent: true });
command = 'open `xcode-select -p`/Applications/Simulator.app';
return shell.exec(command, { silent: true });
} else {
// Xcode 8 or older
command = util.format('xcrun simctl shutdown booted');
shell.exec(command, { silent: true });
command = util.format('xcrun instruments -w "%s"', deviceid);
return shell.exec(command, { silent: true });
}
},

log: function(deviceid, filepath) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simctl",
"version": "1.1.0",
"version": "1.1.1",
"description": "library for Xcode 8+ simctl utility on macOS",
"repository": {
"type": "git",
Expand Down

0 comments on commit 1ec43d8

Please sign in to comment.