2

I want to run an executable file in my iOS app. (or execute some command line commands)

I think this can be done with the help of NSTask, but that doesn't seem to be available in iOS (its available for mac OS X only).

So,

  1. How can i run an executable from my app ? OR How can i execute shell commands from my app ?
  2. How can i make use of NSTask in iOS ?
  3. Are there any other libraries like NSTask which i can make use of ?
  4. If none of the above is possible, please let me know a way around.

I want my app to be uploaded on the app store, so please don't answer anything related to jailbreaking.

Also, Don't tell me apple would reject it, i want to take a chance.

Ashish
  • 355
  • 2
  • 5
  • 9

1 Answers1

2

You can't run an executable from your app due to the sandboxing. From the list 1-4 are not possible.

NSTask is not available because it would violate the sandboxing.

zaph
  • 111,848
  • 21
  • 189
  • 228
  • See answer. Apple has closed down code execution because it is a potential security violation avenue. – zaph Jul 24 '14 at 14:24
  • I can't even run a shell script ? – Ashish Jul 24 '14 at 14:35
  • Shell scripts can not be run. You can run any code that is compiled into your app—only. That too would break sandboxing. I suspect that Apple has thought this out rather well. ;-) – zaph Jul 24 '14 at 14:41
  • Oh... Then what's the run script that can be added in the build phase ? – Ashish Jul 24 '14 at 14:43
  • 1
    The Run Script runs as part of the building the app only, it is not a part of the app. – zaph Jul 24 '14 at 14:44
  • Apple has everything else but though this out. Having worker threads is very important for software stability and to keep memory fragmentation low. – Lothar Feb 14 '18 at 17:56