iPad = computer
AppStore Tools

Unix / CLI / shell-like tools for iOS

So you have an iPad, but you are also used to command-line tools from the Unix world, or you have colleagues who use these tools, and you need to interact with them, or... In short, you'd like to access command-line tools from iOS.

Well, I've got good news and I've got bad news.

The iPad as a computer

The iPad is a powerful tool. Especially for the "Pro" versions,it has a powerful processor, more than enough memory and storage space and a sizeable screen. All this while being very light.

But the iPad also runs iOS, which enforces limits on the apps you can run. iPad users are face with a dilemn: they'd like to use it "like any other computer", but they can't. There are three limitations:

In the old times, a possible solution was to jailbreak, at which point you could run any kind of shell and compiler, and thus install any apps you needed. I may or may not have done this with an iPad 1, and installed texlive on it using gammalevel instructions.

Jailbreaking is becoming harder. To the best of my knowledge, there is no solution available for iOS versions above 10.2.1. The good news are:

Together, these removed two of the main restrictions. So what's the current state of affairs?

Tools from the AppStore

There are several tools on the AppStore that reproduce command-line tools or programming languages:

The last three are not programming languages, but useful tools. And they are open-source.


All these apps are great, but they don't do exactly what I need. Most of my colleagues use hg for source control, I use luaTeX for typesetting, etc. So I looked into sideloading. The good news is, you can port almost anything to iOS, if you are ready to do a bit of code editing. The bad news is, well, you'll have to look into the code of your favorite tool or language.

The idea is simple: first, you need a host app, which will take care of the user interface. Second, you need the source of your favorite tool (ls, tar, curl, TeX...). Edit the tool source so it creates a library instead of an executable, and link with the host app.

You will have to change the tool source in the following ways:

The idea behind all these changes is that your tool will run inside the host app, not outside. So a call to exit() kills both the tool and the host app. Similarly, the memory allocated for the tool remains active inside the host app. If you don't release it or set it to zero, it will be there the next time you run the tool. With the values from the previous run.

Once you've done this, you need to edit the source of the host app, so that when you type ls, it calls the function ls_main in a thread (for exit), and link it with the library you created in the first step.

I've done this porting with three different apps. If you want to test:

What sort of commands are available?

Well, you need the source, and you need to cross-compile. So open-sourced tools, with a reasonably modern implementation and not relying too much on autoconfig tools. Apple OpenSource initiative is a great starting point. You want the source for the MacOS tools, obviously.

What I've already done:

All these commands are available as a single framework, iOS_system, which provides a drop-in replacement for the system() call in the source.

For programs like python and TeX, what you have with the library is only the equivalent of the executable. You still have to install the packages and files, probably by transferring them from an existing installation, because running make install is not possible. Which is why you have to start with the other commands: curl and tar to transfer the files, mkdir and mv to move them where you need them, rm to remove failed attempts.

Also, with TeX, you'll have to re-generate the format files with pdftex --ini --etex pdflatex.ini and the likes.

What are the limitations?

Possible extensions