iPad Pi

iPad Pro with Raspberry Pi 4 attached via USB-C

Beware, this is a geeky one 🤓.

Earlier this year, I updated my status on using the iPad as a computer. In that post I highlighted two obstacles: Ergonomics and Web Development. For the first issue, some of the problems were alleviated by (finally) getting proper mouse support, and the wonderful 'Magic Keyboard'. I had high hopes for external screen support (not just mirroring) at this year's WWDC in June, but it came and went without any news.

As for Web Development, you still can't run a webserver on the iPad, but, you can attach a Rasberry Pi! The latest incarnation of the Pi (#4) uses USB-C for its power source, allowing a single cable to connect the Pi to the iPad and get both data and power supply from it. This works particulary well with the Magic Keyboard, as you can power both devices through its USB-C port (which can do power, but not data), leaving the iPad's free to connect the Pi.

Pi 4 in its packaging

Obviously, any 'normal' computer easily run a webserver, but I really enjoy working on the iPad and tinkering, so wanted to see if it was possible. But why use an add-on piece of hardware, instead of SSHing into a remote server? For me the big advantage is file transfer. I can set up a Samba share on the Pi, and have those directories appear in the native Files app on the iPad. I can then edit text files in a code editor app rather than use terminal (VIM, Nano etc) or a browser-based instance of Visual Studio. Other assets like images can also be saved directly to the Pi via the iPadOS save dialog.

The Pi 4 is small and light (and if you could remove the redundant USB and ethernet ports it could be even smaller) and can be bought for as little as £34 for the 2gb memory option. I decided on the 4gb for a bit more oomph, and a nice aluminium case to protect it. Setting up the SD card on the Mac was super simple with the Rasberry Pi Imager app.

The imager app has just three steps - choose an OS, an SD card and then press write

For the initial setup, you'll need a separate monitor, keyboard and mouse, but once configured you can attach over VNC (using the Screens app) and SSH. VNC is sluggish, but useful for some setting up tasks. You'll mostly want to use the command line to interact with the Pi though, which means using SSH. More on that later.

Raspberry Pi, viewed on the iPad Pro via Screens app

The first part of the process is to setup the Pi so that it can be used as an 'Ethernet Device' on the iPad. This has quite a few steps, but is very well documented over on MagPi Magazine's article. A summary of the process is:

  • Setup the Pi as a USB device and give it a fixed IP
  • Enable SSH
  • Enable access over VNC
  • Install Samba and setup a folder to share
Final assembled Rasberry Pi 4 in its aluminium case, connected to the iPad via USB-C

These steps were more straightforward than I expected and took me about 30 mins. So far, so good! But here's where the instructions run out, and I still haven't setup the web server. There are a few more installations to do, but now I can access the Pi via SSH to do this. I tried out quite a few SSH apps, but they all suffer from a limitation where the connection will drop if it's in the background for longer than 20 seconds. If, like me, you spend a lot of time googling for shell commands to install things and then switching back to the terminal, you can find your connection has been lost and you have to start again.

The key here is the Blink Shell app, which supports Mosh (Mobile Shell), so that connections stay open. To make use of this, you first need to install Mosh on the Pi:

sudo apt-get install mosh

With Blink, the whole screen is devoted to the terminal, which means that opening the app for the first time is a little daunting. No visible UI, just a command line prompt that says 'blink >'. Stick with it though, because there's a lot there, it's just not immediately obvious. For example, you can use your standard keyboard shortcuts to create and navigate between other tabs. I particularly like being able to add a pre-configured host (in this case I called it 'Pi') so that all I have to do is type:

ssh Pi 

…and I'm connected! It even supports external displays (although I would never need a terminal that big).

Blink Shell app running on the iPad Pro
Blink Shell app running on the iPad Pro

Setting up the stack

Now I can install the web stack, and my needs are fairly simple: Apache, PHP, Node and Git. Your needs will be different, but whatever you need to install the first step is always to update the package manager:

sudo apt update

Then I installed Apache, PHP, Git, Maria (MySQL), Composer and Node:

sudo apt install apache2 -y
sudo apt install php libapache2-mod-php -y
sudo apt updatesudo apt install git
sudo apt install mariadb-server mariadb-client -y
curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt install nodejs

I should point out that when it comes to this part I'm a copy-and-paster, and I'm aware that you shouldn't always install things as a root user (sudo), so do get a second opinion before doing any of this.

Setting up Virtual Hosts

The final part I needed to get working was virtual hosts, so that I could view different sites on the iPad. I followed the instructions by Ste Wright. So far, I've only got it working via different port numbers, not named servers, but that's enough.

One step of this that's worth reiterating is that after adding a new host, you'll need to enable it, which creates a link from /sites-available/ to /sites-enabled/. This can only be done via command-line (copying the file won't work). In my case, I called the conf file 'vhosts' so to enable the virtual host I did:

a2ensite vhosts

Don't forget to restart apache after you've done:

systemctl reload apache

And finally… I can run a server and view it in Safari! Finally, when I'm finished, I can shut down the Pi with:

sudo shutdown -h now

Or turn it off using the Raspbian GUI in Screens app.

Conclusion

Enough about all the technical setup, does it work? Why, yes it does!

I found following the instructions for initial setup were straightforward. The hardest part of the setup (for me) was the webserver part, running into issues with permissions and dependencies. An experienced developer won't have these issues, but I got so much further than I expected.

Pros

  • It's small, inexpensive, light and it actually works.

Cons

  • First of all, it shouldn't be necessary.
  • Secondly, I've had some issues with the Pi dropping connection, and being a headless setup makes it hard to know what happened. My guess is that the USB-C cable came out slightly, and the power went off.
  • Also, running the webserver is only one part of the deal - we still need better inspection tools and the ability to test in different browsers (all iPadOS browsers use the same rendering engine). Using the Screens app, you can use Firefox or Chrome on the Pi for better webdev tools, but this is a slower way to work.

The arrival of the M1 Silicon Macs might make this all moot. From all accounts, the speed and snappiness that draws me to the iPad has finally come to MacBooks. It also brings the ability to run iOS and iPadOS apps, so surely touchscreens can't be too far off? For now, this is a good enough setup, maybe not as a full-time solution, but to support my MacBook Pro.

List of apps used

Blink Shell Icon
Blink Shell(SSH)
Screens Icon
Screens (VNC)
Textastic Icon
Textastic (code editor)
Working Copy Icon
Working Copy (Git)

Contact

Call Jon Hicks on +44 (0)7917 391536
Email
Tweet @hicksdesign

Hicks Design
Wenrisc House
Meadow Court
Witney, OX28 6ER
United Kingdom