brigadir brigadir - 8 months ago 47
Bash Question

From iOS app on Simulator, launch OS X shell script

Is it possible from inside iOS app code to run Mac OS X shell script (or any other OS X program)?

The concrete situation is following: I'm playing with UI XCTests and want to run shell script in

methods of test cases. The purpose is to launch screen recording while the test is running.


Okay, looks like nobody knows easy workarounds. So I solved it with local web-server on python.

Python has built-in BaseHTTPServer class. With this tutorial for example: we can write simple web-server to handle POST request and performs some action.

In my case the action is to call bash script


To launch all this mechanism we need to run python webserver. Then inside XCTestCase subclass in setup() and tearDown() methods we perform request to the server, ex:

    AFHTTPSessionManager().POST("", parameters: params, success: { (NSURLSessionDataTask, AnyObject) in
    }, failure: { (NSURLSessionDataTask, NSError) in