0

Does Apple provide a way for an iOS app (running on a connected iPhone or the simulator) to execute a shell command on the host Mac? This is to help with development/debugging. I want to be able to tap a button in the app and have it run a script on the Mac.

I have a working solution that involves running a server on the Mac and having the iPhone talk to it but was wondering if there's another approach provided by Apple. UIAutomation's UIAHost looked relevant but I want to run the command without Instruments.

ide
  • 19,942
  • 5
  • 64
  • 106
  • Someone which 4k+ reputation should understand and know the question type we accept and do not accept in this community. – Daryl Gill Aug 15 '14 at 23:18
  • I added some more details to the question but I think it's totally reasonable even if there are several approaches. Tons of helpful questions are open-ended e.g. looking at related questions http://stackoverflow.com/questions/22358/how-can-i-develop-for-iphone-using-a-windows-development-machine – ide Aug 15 '14 at 23:45

1 Answers1

1

As long as you are running under the debugger you can use a symbolic breakpoint to execute a shell script.

In your view controller, create an IBAction handler for your button. It can be empty. Wire it up to your button as you would normally.

Then, in the Breakpoint Navigator in Xcode, add a new Symbolic breakpoint. Set the symbol to - [MyClass myButtonHandler] and set the action to execute a shell script and set the checkbox to automatically continue after the breakpoint.

Paulw11
  • 108,386
  • 14
  • 159
  • 186