Search code examples
iosunixdarwin

What shell commands can you access on iOS via the "system" command in Objective-C?


I know that both Mac OS and iOS are based on Darwin OS. Does this mean all the OS X commands available in Terminal are available on iOS using the "system" command in Objective-C? If not, which ones are?


Solution

  • No, there is no shell available on an un-jailbroken iOS, and hence system() doesn't do anything useful. Adding a shell is apparently a common thing to do on jailbroken devices.

    Most of the user-mode C/C++ run-time library is available in modern versions of iOS (I haven't worked with versions older than 9) so quite a lot of classical UNIX code can work. Writing an app with a shell user interface should be possible, but it isn't very useful without jailbreaking, for at least two reasons:

    1. An app only has access to its own directory hierarchy, and thus can't see other apps' files.

    2. iOS apps are not designed to be administered via a command-line interface.

    I suspect Apple would also reject any submission of a command-line app to the App Store.