iPhone DevOps
iPhone DevOps (2023)

原始链接: https://clearsky.dev/blog/iphone-devops-ssh/

## 一手掌控的移动开发 作者最初梦想仅用iPhone进行开发,最初依赖Pythonista。但为了应对[protohackers](https://protohackers.com/) 中的复杂客户端-服务器协议,作者不得不改进工作流程。核心问题是iPhone难以打开端口进行服务器测试。 解决方案是巧妙地结合了几个应用:**Secure Shellfish** 提供与远程VPS(目前在Contabo)的离线文件夹同步,允许在手机上编辑代码,并使更改立即反映在服务器上。**Textastic** 作为编辑器,访问同步的文件夹,而 **Working Copy** 处理Git版本控制,也集成到同步目录中。 这套配置成本约为€60 + VPS每月€7.25,可以进行Golang等语言的编码,即使抱着孩子也能操作!虽然速度不如笔记本电脑,但它是一种充实的替代方案,避免了无意义的滑动,并能有效地利用空闲时间。作者承认编辑器仍有优化空间,但目前正享受这种独特的移动开发体验。

相关文章

原文

I wrote earlier about my dream of developing “single-handedly” on an iPhone. Then, I wrote some more about it. The dream still lives strongly! I am now coding single-handedly in any language on my iPhone SE model 2022. But although i still like pythonista I am now using a combination of three great apps that allow me to write code in any language using only one hand, holding my son in the other!

what happened to pythonista? Wasn’t it awesome because it could copy-paste and stuff?

Pythonista still is a great app. An update came out early this year featuring a much-needed python version push to 3.10. I still like to use the app for small scripts such as Advent of Code.

A new quest

So what disturbed the bliss of my little pythonista-powered mobile dev heaven? I blame protohackers. The day I found this site, I knew i had to go back to the drawingboard for my mobile dev workflow.

The idea for protohackers is this: the site gives you a spec for a client-server protocol. You have to implement the server. You then plug the ip and port of your running server into the website, and it runs a series of tests interacting with your server. You have to make all tests pass. You can implement your server in any language you like. The specs are mostly watertight, although there are some surprises in the tests. The protocols are on top of either TCP or UDP. Overall these challenges are really well designed and a lot of fun to implement. My solutions are here

So i wanted to do these challenges, but my workflow could not support it:

  • I cant just open up a port on my iPhone. It sits behind a router at home, or some kind of NAT outside. Even if I could, I don’t know if it would be a good idea security-wise.
  • I don’t want to do this one in python. I want to use this challenge to gain some more experience in golang

The search is on (again)

After revisiting all the options from my earlier searches, and looking at a bunch of code editors/ide’s, I was just ready to start vim in a terminal and start working completely on my server.

I was using termius which is a pretty nice terminal app even when you use the free version. But i decided to do a quick search for terminal apps and see if anything popped out that would work even better. And that’s when it happened.

I found secure shellfish

Secure shellfish

I wouldn’t call it the best terminal app, because the menus are a bit hard to navigate and some design choices are a bit… creative. But in spite of that, I love it! Mostly because this app has 1 killer feature:

✨Offline folders ✨

This is like rsync for your phone. In fact I would not be surprised if this is implemented using rsync. Once you configure an offline folder, it will two-way sync that folder while you use the app. The kicker is: on your phone you can now open that folder in another app (like an editor) and make changes. When you switch back to the shellfish app, the changes are uploaded almost instantly. Also changes that happen on the server come back to the phone.

Offline folders
Offline folders

For me this is a killer feature because it allows me to switch back and forth between the editor and the shell.

  • Make a change
  • switch to shellfish
  • up arrow enter
  • back to the editor
  • repeat!

The place to run code

So now that my code doesn’t run on the phone anymore, it needs a place to run.

I already had a vps running, so for me this was not a problem. Any linux based machine will do. I use docker to easily spin up environments for each project. I am on a contabo vps which has really nice specs for money, but I did have some outages lately. I might switch provider soon.

Ofcourse if you are on a budget, ypu can use any linux machine you have running at home.

The editor

So now we need to find an editor that can open the “offline folder”. I landed on textastic which has its own sftp functionality and even a shell builtin. I didnt get that to work smoothly. The app allows you to open “external folders” which is how you can reach the shellfish folder.

External folders
Two synced folders from my vps and one stored locally by working version

The syncing works really well. I have seen one problem which is that if you type something and then switch the shellfish app, it doesn’t seem to sync the file. It looks like textastic didn’t save the file. My workaround is to move the cursor, just tap anywhere in the file before switching away from the editor.

Other features that this editor does well is search/replace, search in files and file management (move, rename etc)

Im not sure if other editors can do the “external folders” trick, or if textastic is the best one. So far it works really well. There’s room for improvement here, I might test some other editors and write a follow-up some time.

The version control

I use git mostly as a backup for my code. I have my own git server for private projects and github for public. Now I could use the commandline git and commit that way. That works okay, but I really like the working copy app. It can attach to the same “external folder” and you are off to the races! This app is made by the same developer as shellfish.

The euros

Good things have a price. Here’s the full damage report:

  • shellfish life unlock: € 24,99
  • textastic € 9,99
  • working copy life unlock: € 24,99
  • contabo vps: € 7,25 / month

Shellfish and working copy also have subscription-based pricing which is great if you are unsure if mobile dev will work for you. I went for the fixed price and am pretty sure I’m going to enjoy these apps for quite some time.

The conclusion

The conlusion remains the same as the previous editions: it works, but not for impatient people. It has become my alternative to social media. While it might be a lot less effective than a laptop, it’s definitely a lot less mind-numbing than instagram.

With that, let’s get back to writing some code!

联系我们 contact @ memedata.com