I mostly work and play within the Apple ecosystem and AirDrop, Continuity and other integration between devices is extremely useful and convenient. My son recently converted himself to Linux and started to miss the ability to easily move photos, text, or url between his phone and his Linux computer. Being a hacker himself, he thought it would be a great idea to devise an app that let’s you move information from your phone to your computer, and more generally a “cross platform AirDrop substitute for geeks”…
Of course, one solution would be to google and figure out if such an app exists, but where is the fun in that? We decided to take on a Father-Son new project and build our own solution.
The result ended up surprisingly useful, we made it open-source, you can find the working code here and the app on the store. As we learned a few new technologies along the way, we decided to write about the approach as hopefully it could be useful to other.
In this first part, we’ll go over the overall approach, then the iPhone Application implementation and finally the python implementation on the computer.
My son’s philosophy being “anything beyond using a socket API and crafting your own network packets would be too high level”, he started writing some C code, building his own protocol, communicating with a cloud server he rents on Digital Ocean with his weekly allowance.
I wanted to take the opportunity to show him how to leverage higher level libraries even languages like python to get the desired result quickly. We targeted to get a proof of concept, including learning the require component within one week-end. No choice but to leverage existing frameworks…
The philosophy of the tool would be on the phone to be as user friendly and natively integrated to the phone system as possible. On the computer it would be natural for a linux geek, command line based and loosely inspired by some of the
git concept of
stash. No fancy UI and definitely no mouse. Using the mouse is probably more of an heresy for my son that using a high-level library. He lives in the terminal, emacs and the i3 tile window manager. We would also try to be as generic as possible on the items that could be shared, images, text, files, but start with the basic he needed: text, url and photos.
We needed to decide on three core components: how to store and track the items to be shared – the stash, how the devices would discover each other on the network and how to share the actual items on the network across devices
We needed to keep that simple. No database or anything complex, we went for a linux like approach of keeping a dot directory in the home of the user where the supporting files would be kept as well as the actual items themselves saved as files.
The gold standard for service discovery seems to be Bonjour or ZeroConf. It appears to have started as an Apple technology, but is a standard used by most device these days. A quick review of the docs showed that it was exactly what we needed. Enables discovery of devices services on the network and we should share small payload of information as well. And of course it was multi-platform with convenient library in the Apple iOS development environment and python.
The most obvious approach to share files between devices seem to be using http/https. Widely supported, easy to debug with many existing tools and of course it supports all kind of format that we needed. python and iOS have great support to do requests and good libraries to implement simple servers. One issue was that on iOS, an app needs to use the https protocol, but a quick search lead to a great little library to implement a server that supports https on iPhone called Criollo.
Last Missing Pieces
Before we could really start, two major pieces remained to be agreed: the name and the icon!
Again two philosophies and two contenders for the name. The teen cool factor approach:
Galactic Clipboard or the middle-age practical and plain one:
Remote Stash. Because I was quicker to create the GitHub repo and I control our Apple Developer account for the App, I won with RemoteStash…
The Icon was less contentious. Turns out a teen living in an emacs and terminal environment is less interested in icons, so I quickly put one together
Next we’ll look how we implemented the iPhone app before looking at the python script
But first you can see a video demo of the tool