Improve iOS simulator behavior
This commit is contained in:
@@ -263,26 +263,21 @@ class IOSHelper {
|
||||
|
||||
}
|
||||
|
||||
ProcessHelper.runCommand ("", "open", [ "-a", "Simulator", "--args", "-CurrentDeviceUDID", currentDeviceID ], true, true);
|
||||
ProcessHelper.runCommand ("", "open", [ "-a", "iOS Simulator", "--args", "-CurrentDeviceUDID", currentDeviceID ], true, true);
|
||||
try {
|
||||
|
||||
while (true) {
|
||||
ProcessHelper.runProcess ("", "open", [ "-Ra", "iOS Simulator" ], true, false);
|
||||
ProcessHelper.runCommand ("", "open", [ "-a", "iOS Simulator", "--args", "-CurrentDeviceUDID", currentDeviceID ]);
|
||||
|
||||
output = ProcessHelper.runProcess ("", "xcrun", [ "simctl", "install", currentDeviceID, applicationPath ], true, true, true);
|
||||
} catch (e:Dynamic) {
|
||||
|
||||
if (output != null && output.toLowerCase ().indexOf ("invalid device state") > -1) {
|
||||
|
||||
Sys.sleep (3);
|
||||
|
||||
} else {
|
||||
|
||||
break;
|
||||
ProcessHelper.runCommand ("", "open", [ "-a", "Simulator", "--args", "-CurrentDeviceUDID", currentDeviceID ]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
waitForDeviceState ("xcrun", [ "simctl", "uninstall", currentDeviceID, project.meta.packageName ]);
|
||||
waitForDeviceState ("xcrun", [ "simctl", "install", currentDeviceID, applicationPath ]);
|
||||
waitForDeviceState ("xcrun", [ "simctl", "launch", currentDeviceID, project.meta.packageName ]);
|
||||
|
||||
ProcessHelper.runProcess ("", "xcrun", [ "simctl", "launch", currentDeviceID, project.meta.packageName ]);
|
||||
ProcessHelper.runCommand ("", "tail", [ "-f", "~/Library/Logs/CoreSimulator/" + currentDeviceID + "/system.log"]);
|
||||
|
||||
} else {
|
||||
@@ -349,4 +344,27 @@ class IOSHelper {
|
||||
}
|
||||
|
||||
|
||||
private static function waitForDeviceState (command:String, args:Array<String>):Void {
|
||||
|
||||
var output;
|
||||
|
||||
while (true) {
|
||||
|
||||
output = ProcessHelper.runProcess ("", command, args, true, true, true);
|
||||
|
||||
if (output != null && output.toLowerCase ().indexOf ("invalid device state") > -1) {
|
||||
|
||||
Sys.sleep (3);
|
||||
|
||||
} else {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -284,7 +284,7 @@ class ProcessHelper {
|
||||
|
||||
}
|
||||
|
||||
return _runProcess (path, command, args, waitForOutput, ignoreErrors);
|
||||
return _runProcess (path, command, args, waitForOutput, safeExecute, ignoreErrors);
|
||||
|
||||
} catch (e:Dynamic) {
|
||||
|
||||
@@ -300,14 +300,14 @@ class ProcessHelper {
|
||||
|
||||
} else {
|
||||
|
||||
return _runProcess (path, command, args, waitForOutput, ignoreErrors);
|
||||
return _runProcess (path, command, args, waitForOutput, safeExecute, ignoreErrors);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static function _runProcess (path:String, command:String, args:Array<String>, waitForOutput:Bool, ignoreErrors:Bool):String {
|
||||
private static function _runProcess (path:String, command:String, args:Array<String>, waitForOutput:Bool, safeExecute:Bool, ignoreErrors:Bool):String {
|
||||
|
||||
var oldPath:String = "";
|
||||
|
||||
@@ -390,6 +390,10 @@ class ProcessHelper {
|
||||
|
||||
output = error;
|
||||
|
||||
} else if (!safeExecute) {
|
||||
|
||||
throw error;
|
||||
|
||||
} else {
|
||||
|
||||
LogHelper.error (error);
|
||||
|
||||
Reference in New Issue
Block a user