Has anybody had any success calling a system bash command via objective-c from the simulator? I have considered doing this over a SSH connection but this is likely to be a quite laggy, so wondered if there was a more direct method. The idea behind this is to allow fast development of logging features in ruby... These calls would be stripped out of the live deployed app, therefor private calls would be fine for this.
Asked
Active
Viewed 1,004 times
0
-
`NSTask` does this. I'm not sure though if that is an OS X only class. – 11684 May 28 '13 at 07:58
-
BTW if you think it'll be faster to write your software in Ruby, you might want to investigate [RubyMotion](http://www.rubymotion.com/). – May 28 '13 at 08:17
-
Thanks for your feedback below Graham. I'm not interested in writing iOS apps in RubyMotion here, I just wish to quickly pipe some data to ruby during development for testing purposes. Should the system call below work I'll go with that. Cheers. – Kzrbill May 28 '13 at 10:57
1 Answers
3
You can do that, it works as you might expect on a UNIX platform.
int status = system("/usr/bin/say hello");
can be called from a simulator app, and will execute the correct binary.
-
Nice. I wonder why the accepted answer of the [question I linked](http://stackoverflow.com/questions/1536400/nstask-or-equivalent-for-iphone) to says otherwise: – 11684 May 28 '13 at 08:02
-
That's answering a different question. You can call system commands in the iOS simulator, you can't do it on an iPhone. – May 28 '13 at 08:16