OK! Big news- It’s now possible to edit and save Python code on iOS to embedded electronics, CircuitPython USB devices!

This is a follow up to our post about Apple’s iOS 13 beta, which is now up to beta 5.

The upcoming iOS 13 allows iPads (and iPhones) to be more like computers, which means you’ll be able to do computer-like things such as plugging in a USB drive, opening up the Files app in iOS 13 and browsing the files. This is going to be fantastic for folks who want to use an iPad as their full-time desktop replacement, and if you’re a coder it looks like you’ll be able to do things like opening up Python .py files, use IDEs for coding, etc. A lot of schools use iPads, so this means any iPad will be able to be used to code for electronics: if the app can open a text file, it can be used to write Python.

iOS 13 beta 1 had some troubles: it deleted files off some devices that act like USB drives, for example, all the CircuitPython boards. But now the GOOD NEWS: we filed a bug report, and since iOS beta 5 IT IS ALL WORKING! This means any code editor for iOS can be used as a code editor for CircuitPython and you’ll be able to open, edit, and save your code to the device(s) plugged in to the iOS device!

Here’s a quick summary of how to edit a CircuitPython file now on an iPad running iOS 13 beta 5: plug in a CircuitPython board, such as a Circuit Playground Express, select a file on CIRCUITPY, drag or copy/paste the file to “On My iPad”, use an editor to change the file, then delete the original file on CIRCUITPY, copy/paste, share, or drag the file back to CIRCUITPY, giving it a new name, rename and it all saves and runs automatically. It’s awesome. The code editing apps are not aware of this new “USB storage” in iOS 13 yet; when they are (soon), it will be even easier. For now, just use the iOS Files app to move the files around.

Also, iOS 13 beta 5 clearly still has some bugs: you can’t save the file with its original name, so you need to to save with a new name, delete the old file, and rename the new file.

We are currently using iOS 13 beta 5, released on July 29, 2019.

After loading the latest iOS 13 beta, we plugged in the Circuit Playground Express via USB to the iPad using the “Lightning to USB Camera Adapter.” For my demo, I have a code.py file on the device that runs the rainbow pattern. Once plugged in to the iPad, the Circuit Playground Express powers up and runs the program that is on the device (code.py).

On the iPad tap the FILES app icon.

Then, tap Locations > Browse and tap CIRCUITPY, that is the “USB Drive” that has the python code.

These are all the files on my Circuit Playground Express as viewed via the iPad.

Press and hold the code.py (displayed as code since it does not show the file extension at this time and/or I do not know the setting to change that). Tap COPY.

Browse to the local file system (“On My iPad”) and paste the code.py file. Alternatively, you can drag code.py to “On My iPad”, though the dragging doesn’t seem to work all the time.

Now pick an app that can edit code. For the app to test out opening, editing, and saving the Python code that is on the Circuit Playground Express, we are using Koder. What is Koder?

Koder is a code editor for iPad and iPhone. It does have many features including syntax highlighting, snippet manager, tabbed editing, find and replace code, editor theme, remote and local files connections, and many more. With Koder you can code anytime and anywhere, no matter if you’re at your desk or while on the go.

There are other apps for code editing on iOS (post your suggestions in the comments), this is one that I happen to use. We have also tried Textastic, and it also works.

Open up code.py, in Koder I tapped Files, and then tapped the pad of paper with pencil icon.

Click “Open Other Apps’ File” and open code.py

Edit the code!

Next up, after editing, go back to the FILES app, copy the saved code.py on the local iPad storage, then browse to CIRCUITPY and paste the file. iOS at this time will name it code 2 and does not overwrite it, so rename the current code.py (I used _code) and then rename the one that was just pasted to the CIRCUITPY drive. With CircuitPython, saving the code, and/or saving a file to the USB “drive” automatically starts the device and will run the code, again – automatically.

If you’re trying this with Textastic, the work flow is a little different. You can share the file from “On My iPad” to Textastic. Then edit the file. Then touch the Share icon in Textastic (in the three dots menu in the upper right), choose “Save to Files”, and save the file with a new name. Then go back to CIRCUITPY in the Files app, delete the old file, and rename the new one to the old name.

iOS 13 beta 5 clearly still has some bugs: you can’t save the file with its original name, so you need to to save with a new name, delete the old file, and rename the new file.

That’s it, it “just works” and it is really a great experience to code on my iPad with CircuitPython running on Circuit Playground! I’ll make a little video later, going to code on the couch with my iPad and CPX now 🙂