Ensure stopApplication works correctly #90
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
stopApplication
method callskillall
command, which does not terminate the process immediately. So trying to restart the application, which isstopApplication
followed by immediatestartApplication
call, fails with some strange error, that theapp 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 axcrun 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.