Using an iPad for Dev
Tags: ipad, devjournal
Published: 2021-10-03 07:44:29

Anyone that says you can use an iPad for software development actually mean “I can SSH into a remote server and kinda do stuff”. Admittedly there are some apps like Scriptable and Pythonista 3 that allow you to execute code locally on device, but they lack some of the freedom you have executing code on an actual computer.


I recently acquired an iPad Pro and, like a normal person, the first thing I did was set it up for software development.

## But why?
An iPad is probably the best tablet experience you can get - but it comes with the downfall of a terrible experience for software dev. With the latest iPads advertising their keyboard and mouse support, and their external monitor capabilities it feels like they’re pushing into thin client territory and I want to try maximise this devices utilisation.

## Prerequisites
Using an iPad comfortably for software development work requires a rather niche set of conditions to work.
Firstly, you have to be comfortable using just terminal for development (tmux + nvim users I’m looking at you) and secondly you need a desktop/server you can SSH into. If you don’t own a pc and you want to get into software dev… don’t buy an iPad first.

## But my precious IDE?
But how do I do all the fancy things my IDE does in terminal? I need them! Well with the changes that have come through in Neovim 0.5, you can now use Neovim as a fully fledged IDE. By using tree-sitter, nvim-compe, nvim-dap you can get all the nice features of IDE’s such as autocomplete, definition and reference jumping, and most importantly the ability to debug. There’s a plethora of tutorials on how to do that so I want touch on it here. 

Now just have a nice text editor isn’t enough, that’s your whole terminal window gone! So by adding tmux into the mix we almost have a tiling manager (as long as its a terminal application).

## The iPad Setup
Now for this to work, you need a terminal emulator app. The best terminal app I’ve found is blink shell. It supports multiple simultaneous connections, setting up hosts, split view and most importantly Mosh. 

### What’s Mosh?
Mosh is a mobile shell, with an emphasis on mobile. It uses UDP instead of TCP (like SSH does), so you aren’t plagued by things like your SSH session time outs because you’ve switched wifi networks or to 4G, or even put your iPad to sleep. All in all it means that Mosh is the superior choice for your mobile shell needs. Given that you’re coding on an iPad, the ability to put the device to sleep then wake it up and resume is a killer feature. 

## Setup
1. Install openssh-server, neovim and tmux on your desktop. (This will depend entirely on your distro)
2. Launch blink, type config and hit enter
3. Change the default username to yours
4. Go keys => + => create new => and enter in a name and click save
5. Go back to the main menu and go hosts => + => and fill out host, host name, user and key.
6. `ssh-copy-id key_name_here yourusername@ipaddress`
7. `mosh host_here` and hey presto you’re in!

## Now what?
Well you have a full blown terminal to a powerful remote server… what more could you want?

Did you say port forwarding? Because that’s here!

Blink shell supports port forwarding which means you can run a remote web server and access on your iPad! It follows normal ssh syntax so 
`ssh -L 8080:localhost:8080 yourhost` will forward 8080 on your iPad to the remote server’s 8080 port!

## Conclusion
The iPad is such a wonderful tool in terms of its productivity and creativity potential however, its never really been a software developers go to device. It still technically isn’t, but it makes for a fabulous thin client for those committed enough for on-the-go development and with the new iPad Minis released, a very portable one at that.

You can also plug the iPad into a monitor or Airplay your terminal to a TV if you really wanted to.