Skip to content

Ensure stopApplication works correctly #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 9, 2017
Merged

Conversation

rosen-vladimirov
Copy link
Contributor

@rosen-vladimirov rosen-vladimirov commented May 4, 2017

stopApplication method calls killall command, which does not terminate the process immediately. So trying to restart the application, which is stopApplication followed by immediate startApplication call, fails with some strange error, that the app has started, but has exited since then. In order to fix this, add a timeout after stop is called, in order to ensure the app is dead. However in newer Xcode's there's a xcrun simctl terminate command, which really kills it.
So check the version of Xcode and in case it is 8 or later, use the new command instead of killall. In this scenario we do not have to add some magic timeout as the command works correctly.
However the xcrun simctl terminate command requires application identifier, while the killall command works with application name. So I've added another paramter to the stopApplication definition, which should be passed from CLI when calling this method - the applicationIdentifier will be used when Xcode 8 or later is installed, appName will be used for earlier versions.

stopApplication method calls killall command, which does not terminate the process immediately. So trying to restart the application, which is stopApplication followed by immediate startApplication call, fails with some strange error, that the app has started, but has exited since then. In order to fix this, add a timeout after stop is called, in order to ensure the app is dead. However in newer Xcode's there's a `xcrun simctl terminate` command, which really kills it.
So check the version of Xcode and in case it is 8 or later, use the new command instead of killall. In this scenario we do not have to add some magic timeout as the command works correctly.
However the xcrun simctl terminate command requires application identifier, while the killall command works with application name. So I've added another paramter to the stopApplication definition, which should be passed from CLI when calling this method - the applicationIdentifier will be used when Xcode 8 or later is installed, appName will be used for earlier versions.
@rosen-vladimirov rosen-vladimirov merged commit 2cdaa87 into master May 9, 2017
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/sleep branch May 9, 2017 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants