Skip to content

Instantly share code, notes, and snippets.

@stonehippo
Last active May 21, 2022 20:26
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stonehippo/032f3bdb9e92c8b1b15438df6dafea7a to your computer and use it in GitHub Desktop.
Save stonehippo/032f3bdb9e92c8b1b15438df6dafea7a to your computer and use it in GitHub Desktop.
Managing my Working Copy/iPad dev with Github and local repos

Working Copy + iPad + Github + Raspberry Pi == My Dev Setup!

I've been using my iPad Pro as my daily driver at home for a bit. It's a great little computer and I find that it covers many of my needs. But one area where it doesn't quite match what I do is hardware hacking. The iPad doesn't really have the right hardware or software for working with stuff like Arduinos and other microcontrollers. But I've worked around that to that I can still do a lot of my coding on the iPad, while still being able to work with hardware.

With A Little Help From My Friend

The answer to the question "how can I use the iPad to work with hardware development" is simple: all I needed was a helper! In this case, it's a Raspberry Pi 3B+ running Raspbian Lite (sans desktop) and the great PlatformIO. This little single board computer has a few things going for it. It's cheap, small, had 4 USB ports via its onboard hub, and is pretty fast for a system the size of a pack of cards.

My workflow for something like Arduino dev these days looks more or less like this:

  • I write code on my iPad using Working Copy
  • I push that code to a local repo on my Raspberry Pi
  • I SSH into the Raspberry Pi from the iPad
  • I checkout the new code to a local working copy, and compile it with PlatformIO – If everything compiles, I use PlatformIO to flash the new code to a device – At some point, once I'm happy with where things are I push the code to Github
  • Rinse and repeat!

My iPad Dev Environment

I use a few different compnents to make all of this work:

  • my iPad Pro
  • Working Copy - this is a great app. It combines a decent (for iPad, at least) code-oriented text editor with a full featured Git client
  • Github - where I keep my public repos
  • PlatformIO - cross platform framework, board, and library/dependency management tools.
  • A Raspberry Pi 3B+

Some Notes On How I Use Git

In this setup, I have two working copies and two remotes. The "remote of record" is Github. That's where I made my code public and it's a reliable place for me to keep code. I normally start a project locally, then set up a Github remote and push to it to kick things off. I use my local working copy as normal.

I also have a second remote set up locally on my Raspberry Pi, which I set up Working Copy (the app) to use as a second remote for my working copy (the git thing). I restrict this remote to push-only, as I want all of the code to flow one way: from my dev working copy into the local remote.

In addition to hosting the local git repos, the Raspberry Pi has local working copies, cloned from the local repo. I typically only fetch/pull into this working copy, since it's not really something I'm working in. It just exists so I can locally execute build and uploads with PlatformIO. Because that's the case and based on the fact that what I often do after a push in run the build, I'm considering adding a local CI server to the Pi to run the build after each push. That way I can automate a step and get notification when a build fails without having to SSH into the Pi.

Setting Up The Local Remote

A couple of quick notes on how I do this.

  1. On the Raspberry Pi, I create a new bare repo with a name that matches the Github remote.
$ mkdir ~/repos/srv/some-repo-name.git && cd ~/repos/srv/some-repo-name.git
$ git init --bare

Once that's done, I configure working copy on my iPad to use the local server as a remote, which means pointing to something like me@192.168.1.100:repos/srv/some-repo-name.git. I configure the remote as push only. Note that I use SSH to get to my repos.

A quick aside: I use an IP address to refer to my Raspberry Pi for various reasons, but I could also have used its hostname thanks to MDNS advertising, in which case I'd point to me@rpi:repos/srv/some-repo-name.git when setting up the new remote.

Once that's set, I create a local working copy on the Raspberry Pi, too.

$ cd ~/repos/wc/
$ git clone ../srv/some-repo-name.git

Sometimes, A Tortured Path

One area where this setup falls apart a bit is in kicking off new project. For example, I use PlatformIO for my hardware projects. It's really simple to get a new project set up with platformio init on the command line, or from a PlatformIO IDE integration. Unfortunately Working Copy doesn't have the former, and the iPad doesn't have a command line or any way to install the PlatformIO tools (hence this whole setup!).

This means that I have to start on something like the Raspberry Pi if I want to let the tools do the work for me. So I do the following when starting a project new:

  1. On the Raspberry Pi, create a new directory, use platformio init (with whatever options I need)
  2. Create a new, bare repo on Github
  3. git init in the new project folder
  4. Add Github repo as a new remote
  5. Do enough work for an initial commit on the PI (usually just the README and a scaffold in src/main.cpp) then commit and push upstream to Github
  6. Confirm Github got the push, then delete the repo on the RPi
  7. Check out the Github repo to iPad with Working Copy

At this point, this are pretty much ready to go. I follow the steps above to create a new bare repo/working copy on the Raspberry Pi, and set that up as a remote for the iPad.

Not the most elegant solution, but it doesn't take that long to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment